summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-09-18 11:27:18 +0300
committerVaadin Code Review <review@vaadin.com>2015-11-30 13:49:09 +0000
commit715d9ed84666c858c759d27d00b57d629bbe9b7b (patch)
treea944f2927b8a09143b29d170a5b00999b266abc4 /client-compiler
parent5ff2b734d379f31d0f82b4c3cfbb7d39ad05fc03 (diff)
downloadvaadin-framework-715d9ed84666c858c759d27d00b57d629bbe9b7b.tar.gz
vaadin-framework-715d9ed84666c858c759d27d00b57d629bbe9b7b.zip
Fail during compile if required methods are missing (#18924)
A ComponentConnector must override either getWidget or createWidget for the framework to know the type of the component's widget. Similarly either getRenderer och createRenderer must be overridden for AbstractRendererConnector. Prior to this patch, the compilation succeeded when critical methods were missing - the user just got various hard-to-debug issues when the broken connector was used. Change-Id: I6ec07e2f1c1b15047802e64208485b1d999c0aee
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java8
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java10
2 files changed, 17 insertions, 1 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java
index 12e67988eb..2e54d00aab 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java
@@ -52,7 +52,7 @@ public class RendererVisitor extends TypeVisitor {
}
private static void doRendererType(TreeLogger logger, JClassType type,
- ConnectorBundle bundle) {
+ ConnectorBundle bundle) throws UnableToCompleteException {
// The class in which createRenderer is implemented
JClassType createRendererClass = ConnectorBundle.findInheritedMethod(
type, "createRenderer").getEnclosingType();
@@ -63,6 +63,12 @@ public class RendererVisitor extends TypeVisitor {
JMethod getRenderer = ConnectorBundle.findInheritedMethod(type,
"getRenderer");
+ if (getRenderer.getEnclosingType().getQualifiedSourceName()
+ .equals(AbstractRendererConnector.class.getCanonicalName())) {
+ logger.log(Type.ERROR, type.getQualifiedSourceName()
+ + " must override either createRenderer or getRenderer");
+ throw new UnableToCompleteException();
+ }
JClassType rendererType = getRenderer.getReturnType().isClass();
bundle.setNeedsGwtConstructor(rendererType);
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
index a77b523d14..9a9cac18ba 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
@@ -42,6 +42,16 @@ public class WidgetInitVisitor extends TypeVisitor {
// Needs GWT constructor if createWidget is not overridden
if (createWidgetClass.getQualifiedSourceName().equals(
AbstractComponentConnector.class.getCanonicalName())) {
+ if (getWidget
+ .getEnclosingType()
+ .getQualifiedSourceName()
+ .equals(AbstractComponentConnector.class
+ .getCanonicalName())) {
+ logger.log(Type.ERROR, type.getQualifiedSourceName()
+ + " must override either createWidget or getWidget");
+ throw new UnableToCompleteException();
+ }
+
bundle.setNeedsGwtConstructor(widgetType);
// Also needs widget type to find the right GWT constructor