diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-17 16:44:54 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-17 16:44:54 +0300 |
commit | ef87ac540927bff6db259af8f5af9019d588bbbe (patch) | |
tree | e4845a4562943a1a37f183c6630ccdd1827ac12d /client-compiler/src | |
parent | 800efdee9d891fb07343b18bca7cd543ffebb615 (diff) | |
download | vaadin-framework-ef87ac540927bff6db259af8f5af9019d588bbbe.tar.gz vaadin-framework-ef87ac540927bff6db259af8f5af9019d588bbbe.zip |
Clarify logic and add some comments (#9561)
Diffstat (limited to 'client-compiler/src')
-rw-r--r-- | client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java | 27 |
1 files changed, 17 insertions, 10 deletions
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 fe0c579d73..834225edd9 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java @@ -20,25 +20,35 @@ public class WidgetInitVisitor extends TypeVisitor { public void visitConnector(TreeLogger logger, JClassType type, ConnectorBundle bundle) throws UnableToCompleteException { if (ConnectorBundle.isConnectedComponentConnector(type)) { + // The class in which createWidget is implemented JClassType createWidgetClass = findInheritedMethod(type, "createWidget").getEnclosingType(); - boolean needsCreateWidgetSupport = createWidgetClass - .getQualifiedSourceName() - .equals(AbstractComponentConnector.class.getCanonicalName()); JMethod getWidget = findInheritedMethod(type, "getWidget"); JClassType widgetType = getWidget.getReturnType().isClass(); + // Needs GWT constructor if createWidget is not overridden + if (createWidgetClass.getQualifiedSourceName().equals( + AbstractComponentConnector.class.getCanonicalName())) { + bundle.setNeedsGwtConstructor(widgetType); + + // Also needs widget type to find the right GWT constructor + bundle.setNeedsReturnType(type, getWidget); + } + + // Check state properties for @DelegateToWidget JMethod getState = findInheritedMethod(type, "getState"); JClassType stateType = getState.getReturnType().isClass(); Collection<Property> properties = bundle.getProperties(stateType); - boolean hasDelegateToWidget = false; for (Property property : properties) { DelegateToWidget delegateToWidget = property .getAnnotation(DelegateToWidget.class); if (delegateToWidget != null) { + // Generate meta data required for @DelegateToWidget bundle.setNeedsDelegateToWidget(property); + + // Find the delegate target method String methodName = DelegateToWidget.Helper .getDelegateTarget(property.getName(), delegateToWidget.value()); @@ -60,13 +70,10 @@ public class WidgetInitVisitor extends TypeVisitor { throw new UnableToCompleteException(); } bundle.setNeedsInvoker(widgetType, delegatedSetter); - hasDelegateToWidget = true; - } - } - if (hasDelegateToWidget || needsCreateWidgetSupport) { - bundle.setNeedsReturnType(type, getWidget); - bundle.setNeedsGwtConstructor(widgetType); + // GWT code needs widget type to find the target method + bundle.setNeedsReturnType(type, getWidget); + } } } |