Package com.google.gwt.core.ext.typeinfo

Examples of com.google.gwt.core.ext.typeinfo.JField


  }

  void initializeApiFields() {
    apiFields = new HashMap<String, ApiField>();
    List<String> notAddedFields = new ArrayList<String>();
    JField fields[] = getAccessibleFields();
    for (JField field : fields) {
      if (isApiMember(field)) {
        apiFields.put(field.getName(), new ApiField(field, this));
      } else {
        notAddedFields.add(field.toString());
View Full Code Here


  private JField[] getAccessibleFields() {
    Map<String, JField> fieldsBySignature = new HashMap<String, JField>();
    JClassType tempClassType = classType;
    do {
      JField declaredFields[] = tempClassType.getFields();
      for (JField field : declaredFields) {
        if (field.isPrivate()) {
          continue;
        }
        String signature = field.toString();
        JField existing = fieldsBySignature.put(signature, field);
        if (existing != null) {
          // TODO(amitmanjhi): Consider whether this is sufficient
          fieldsBySignature.put(signature, existing);
        }
      }
View Full Code Here

    boolean isPublic = false;
    boolean isPublicOrProtected = false;
    boolean isStatic = false;

    if (member instanceof JField) {
      JField field = (JField) member;
      isPublic = field.isPublic();
      isPublicOrProtected = isPublic || field.isProtected();
      isStatic = field.isStatic();
    }
    if (member instanceof JAbstractMethod) {
      JAbstractMethod method = (JAbstractMethod) member;
      isPublic = method.isPublic();
      isPublicOrProtected = isPublic || method.isProtected();
View Full Code Here

        }
      } else {
        if (AlternateMessageSelector.OTHER_FORM_NAME.equals(value)) {
          out.println("default:  // other");
        } else if (enumType != null) {
          JField field = enumType.findField(value);
          JEnumConstant enumConstant = null;
          if (field != null) {
            enumConstant = field.isEnumConstant();
          }
          if (field == null || enumConstant == null) {
            throw error(logger, "'" + value + "' is not a valid value of "
                + enumType.getQualifiedSourceName() + " or 'other'");
          }
View Full Code Here

    // Get the types produced by the TypeOracle
    JClassType type = typeOracle.getType(CU_ConstrainedListAsField.getTypeName());
    assertNull(type.isParameterized());
    JField[] fields = type.getFields();
    assert (fields.length == 1);
    JField field = type.getField("field");
    assertNotNull(field);
    JType fieldType = field.getType();
    JParameterizedType fieldParamType = fieldType.isParameterized();
    assertNotNull(fieldParamType);
    assertNull(fieldParamType.getEnclosingType());
    JGenericType baseType = fieldParamType.getBaseType();
    assertNotNull(baseType);
View Full Code Here

    assertNull(inner.isParameterized());
    assertNotNull(outer.isGenericType());
    assertNotNull(inner.isGenericType());
    JField[] fields = inner.getFields();
    assertEquals(fields.length, 2);
    JField field = inner.getField("field");
    assertNotNull(field);
    JType fieldType = field.getType();
    JTypeParameter typeParam = fieldType.isTypeParameter();
    assertNotNull(typeParam);
    assertEquals("V", typeParam.getName());
    JClassType[] bounds = typeParam.getBounds();
    assertEquals(1, bounds.length);
View Full Code Here

    buildTypeOracle();

    JClassType listAsField = typeOracle.getType(CU_ListAsField.getTypeName());
    assertNotNull(listAsField);
    assertNull(listAsField.isParameterized());
    JField field = listAsField.getField("field");
    assertNotNull(field);
    JType fieldType = field.getType();
    JParameterizedType fieldParamType = fieldType.isParameterized();
    assertNotNull(fieldParamType);
    assertNull(fieldParamType.getEnclosingType());
    JGenericType baseType = fieldParamType.getBaseType();
    assertNotNull(baseType);
View Full Code Here

    // Try to resolve annotations, ignore any that fail.
    Map<Class<? extends java.lang.annotation.Annotation>, java.lang.annotation.Annotation> declaredAnnotations = newAnnotationMap();
    resolveAnnotations(logger, jfield.annotations, declaredAnnotations);

    String name = String.valueOf(jfield.name);
    JField field;
    if (jfield.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
      assert (enclosingType.isEnum() != null);
      field = new JEnumConstant(enclosingType, name, declaredAnnotations,
          jfield.binding.original().id);
    } else {
      field = new JField(enclosingType, name, declaredAnnotations);
    }

    // Get modifiers.
    //
    field.addModifierBits(Shared.bindingToModifierBits(jfield.binding));

    // Set the field type.
    //
    TypeBinding jfieldType = jfield.binding.type;

    JType fieldType = resolveType(logger, jfieldType);
    if (fieldType == null) {
      // Unresolved type.
      //
      return false;
    }
    field.setType(fieldType);

    // Get tags.
    //
    if (jfield.javadoc != null) {
      if (!parseMetaDataTags(unitSource, field, jfield.javadoc)) {
View Full Code Here

   * @param realField the java field
   * @param enclosingType the GWT enclosing type
   * @return the GWT field
   */
  public JField adaptField(final Field realField, JClassType enclosingType) {
    JField field = createMock(JField.class);

    addAnnotationBehaviour(realField, field);

    when(field.getType()).thenAnswer(new Answer<JType>() {
      @Override
      public JType answer(InvocationOnMock invocation) throws Throwable {
        return adaptType(realField.getType());
      }
    });

    when(field.getEnclosingType()).thenReturn(enclosingType);
    when(field.getName()).thenReturn(realField.getName());

    return field;
  }
View Full Code Here

  public void testOwnerField() throws Exception {
    JClassType labelType = gwtTypeAdapter.adaptJavaClass(Label.class);
    JClassType buttonType = gwtTypeAdapter.adaptJavaClass(Button.class);

    JField someGwtField = gwtTypeAdapter.adaptField(
        this.getClass().getDeclaredField("someField"), ownerType);
    OwnerField someOwnerField = new OwnerField(someGwtField, MortalLogger.NULL,
        uiBinderCtx);
    assertEquals("someField", someOwnerField.getName());
    assertEquals(labelType, someOwnerField.getType().getRawType());
    assertFalse(someOwnerField.isProvided());

    JField providedGwtField = gwtTypeAdapter.adaptField(
        this.getClass().getDeclaredField("providedField"), ownerType);
    OwnerField providedOwnerField = new OwnerField(providedGwtField,
        MortalLogger.NULL, uiBinderCtx);
    assertEquals("providedField", providedOwnerField.getName());
    assertEquals(buttonType, providedOwnerField.getType().getRawType());
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.typeinfo.JField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.