]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fail during compile if required methods are missing (#18924)
authorLeif Åstrand <leif@vaadin.com>
Fri, 18 Sep 2015 08:27:18 +0000 (11:27 +0300)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 2 Dec 2015 13:38:17 +0000 (15:38 +0200)
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: I9e00e0fb7ef40349f9a07311f3b34047174b5ecd

client-compiler/src/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java
client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java

index 12e67988eb1c768ddb495f1baf9e75f8ff1bd09a..2e54d00aabf64e288f4ccbefa4ac46806466cd10 100644 (file)
@@ -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);
index a77b523d144669ff190033b35dd47a382edd2e75..9a9cac18ba09345a76f6ec25fc8d6ce443ddcf8d 100644 (file)
@@ -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