Reviewers: rjrjr, rdcastro,

Description:
Changing lazy widgets strategy to die in case a given @UiField attribute
has no counterpart in the template.


Please review this at http://gwt-code-reviews.appspot.com/1453806/

Affected files:
  M user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java


Index: user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
===================================================================
--- user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java (revision 10278) +++ user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java (working copy)
@@ -997,6 +997,26 @@
     if (!detachStatementsStack.isEmpty()) {
       throw new IllegalStateException("Detach not cleaned up: "
           + detachStatementsStack);
+    }
+  }
+
+  /**
+   * Evaluate whether all @UiField attributes are also defined in the
+   * template. Dies if not.
+   */
+  private void evaluateUiFields() throws UnableToCompleteException {
+    if (designTime.isDesignTime()) {
+      return;
+    }
+    for (OwnerField ownerField : getOwnerClass().getUiFields()) {
+      String fieldName = ownerField.getName();
+      FieldWriter fieldWriter = fieldManager.lookup(fieldName);
+
+      if (fieldWriter == null) {
+        die("Template %s has no %s attribute for %s.%s#%s", templatePath,
+            getUiFieldAttributeName(), uiOwnerType.getPackage().getName(),
+            uiOwnerType.getName(), fieldName);
+      }
     }
   }

@@ -1374,6 +1394,8 @@
     w.outdent();
     w.write("}");

+    evaluateUiFields();
+
     fieldManager.writeFieldDefinitions(
         w, getOracle(), getOwnerClass(), getDesignTime());



--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to