summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-21 14:13:41 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-21 14:13:41 +0300
commit360f19b82e5b5d5d2646e444f274d5643f93d3d5 (patch)
treeeab67a23903464ec31df292c0d75c53cbde89082 /client-compiler
parent474b7dbcc7abe07f2f16cd200f48723a471926c4 (diff)
downloadvaadin-framework-360f19b82e5b5d5d2646e444f274d5643f93d3d5.tar.gz
vaadin-framework-360f19b82e5b5d5d2646e444f274d5643f93d3d5.zip
Abort compile if there's an RPC method with a return type (#9704)
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java23
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ServerRpcVisitor.java4
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/TypeVisitor.java4
3 files changed, 27 insertions, 4 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
index 3b78519a0d..83aa85b482 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
@@ -19,6 +19,8 @@ package com.vaadin.server.widgetsetutils.metadata;
import java.util.Set;
import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JType;
@@ -26,12 +28,14 @@ import com.google.gwt.core.ext.typeinfo.JType;
public class ClientRpcVisitor extends TypeVisitor {
@Override
public void visitClientRpc(TreeLogger logger, JClassType type,
- ConnectorBundle bundle) {
+ ConnectorBundle bundle) throws UnableToCompleteException {
Set<? extends JClassType> hierarchy = type
.getFlattenedSupertypeHierarchy();
for (JClassType subType : hierarchy) {
JMethod[] methods = subType.getMethods();
for (JMethod method : methods) {
+ checkReturnType(logger, method);
+
bundle.setNeedsInvoker(type, method);
bundle.setNeedsParamTypes(type, method);
@@ -42,4 +46,21 @@ public class ClientRpcVisitor extends TypeVisitor {
}
}
}
+
+ public static void checkReturnType(TreeLogger logger, JMethod method)
+ throws UnableToCompleteException {
+ if (!method.getReturnType().getQualifiedSourceName().equals("void")) {
+ logger.log(
+ Type.ERROR,
+ "The method "
+ + method.getEnclosingType()
+ .getQualifiedSourceName()
+ + "."
+ + method.getName()
+ + " returns "
+ + method.getReturnType().getQualifiedSourceName()
+ + " but only void is supported for methods in RPC interfaces.");
+ throw new UnableToCompleteException();
+ }
+ }
}
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ServerRpcVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ServerRpcVisitor.java
index cbcfc3075b..fa0a8390a4 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ServerRpcVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ServerRpcVisitor.java
@@ -19,6 +19,7 @@ package com.vaadin.server.widgetsetutils.metadata;
import java.util.Set;
import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JType;
@@ -26,7 +27,7 @@ import com.google.gwt.core.ext.typeinfo.JType;
public class ServerRpcVisitor extends TypeVisitor {
@Override
public void visitServerRpc(TreeLogger logger, JClassType type,
- ConnectorBundle bundle) {
+ ConnectorBundle bundle) throws UnableToCompleteException {
bundle.setNeedsProxySupport(type);
Set<? extends JClassType> superTypes = type
@@ -35,6 +36,7 @@ public class ServerRpcVisitor extends TypeVisitor {
if (subType.isInterface() != null) {
JMethod[] methods = subType.getMethods();
for (JMethod method : methods) {
+ ClientRpcVisitor.checkReturnType(logger, method);
bundle.setNeedsDelayedInfo(type, method);
JType[] parameterTypes = method.getParameterTypes();
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/TypeVisitor.java
index 7191093755..93eed7843c 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/TypeVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/TypeVisitor.java
@@ -23,12 +23,12 @@ public abstract class TypeVisitor {
}
public void visitClientRpc(TreeLogger logger, JClassType type,
- ConnectorBundle bundle) {
+ ConnectorBundle bundle) throws UnableToCompleteException {
// Default does nothing
}
public void visitServerRpc(TreeLogger logger, JClassType type,
- ConnectorBundle bundle) {
+ ConnectorBundle bundle) throws UnableToCompleteException {
// Default does nothing
}