Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.FieldDeclaration


    if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
      TypeDeclaration typeDecl = this.scope.referenceContext;
      FieldDeclaration[] fieldDeclarations = typeDecl.fields;
      int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
      for (int i = 0; i < max; i++) {
        FieldDeclaration fieldDecl = fieldDeclarations[i];
        if (fieldDecl.binding == existingField) {
          synthField.name = CharOperation.concat(
            TypeConstants.SYNTHETIC_ENUM_VALUES,
            ("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
          needRecheck = true;
View Full Code Here


    if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
      TypeDeclaration typeDecl = this.scope.referenceContext;
      FieldDeclaration[] fieldDeclarations = typeDecl.fields;
      int max = fieldDeclarations == null ? 0 : fieldDeclarations.length;
      for (int i = 0; i < max; i++) {
        FieldDeclaration fieldDecl = fieldDeclarations[i];
        if (fieldDecl.binding == existingField) {
          synthField.name = CharOperation.concat(
            fieldName,
            ("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$
          needRecheck = true;
View Full Code Here

        ? this.scope.referenceContext.staticInitializerScope
        : this.scope.referenceContext.initializerScope;
      FieldBinding previousField = initializationScope.initializedField;
      try {
        initializationScope.initializedField = field;
        FieldDeclaration fieldDecl = fieldDecls[f];
        TypeBinding fieldType =
          fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT
            ? initializationScope.environment().convertToRawType(this, false /*do not force conversion of enclosing types*/) // enum constant is implicitly of declaring enum type
            : fieldDecl.type.resolveType(initializationScope, true /* check bounds*/);
        field.type = fieldType;
        field.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
        if (fieldType == null) {
View Full Code Here

    // iterate the field declarations to create the bindings, lose all duplicates
    FieldBinding[] fieldBindings = new FieldBinding[count];
    HashtableOfObject knownFieldNames = new HashtableOfObject(count);
    count = 0;
    for (int i = 0; i < size; i++) {
      FieldDeclaration field = fields[i];
      if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
        // We used to report an error for initializers declared inside interfaces, but
        // now this error reporting is moved into the parser itself. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=212713
      } else {
        FieldBinding fieldBinding = new FieldBinding(field, null, field.modifiers | ExtraCompilerModifiers.AccUnresolved, sourceType);
        fieldBinding.id = count;
        // field's type will be resolved when needed for top level types
        checkAndSetModifiersForField(fieldBinding, field);

        if (knownFieldNames.containsKey(field.name)) {
          FieldBinding previousBinding = (FieldBinding) knownFieldNames.get(field.name);
          if (previousBinding != null) {
            for (int f = 0; f < i; f++) {
              FieldDeclaration previousField = fields[f];
              if (previousField.binding == previousBinding) {
                problemReporter().duplicateFieldInType(sourceType, previousField);
                break;
              }
            }
View Full Code Here

          for (int i = 0; i < methodsLength && !definesAbstractMethod; i++)
            definesAbstractMethod = methods[i].isAbstract();
          if (!definesAbstractMethod) break checkAbstractEnum; // all methods have bodies
          boolean needAbstractBit = false;
          for (int i = 0; i < fieldsLength; i++) {
            FieldDeclaration fieldDecl = fields[i];
            if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
              if (fieldDecl.initialization instanceof QualifiedAllocationExpression) {
                needAbstractBit = true;
              } else {
                break checkAbstractEnum;
              }
            }
          }
          // tag this enum as abstract since an abstract method must be implemented AND all enum constants define an anonymous body
          // as a result, each of its anonymous constants will see it as abstract and must implement each inherited abstract method
          if (needAbstractBit) {
            modifiers |= ClassFileConstants.AccAbstract;
          }
        }
        // final if no enum constant with anonymous body
        checkFinalEnum: {
          TypeDeclaration typeDeclaration = this.referenceContext;
          FieldDeclaration[] fields = typeDeclaration.fields;
          if (fields != null) {
            for (int i = 0, fieldsLength = fields.length; i < fieldsLength; i++) {
              FieldDeclaration fieldDecl = fields[i];
              if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
                if (fieldDecl.initialization instanceof QualifiedAllocationExpression) {
                  break checkFinalEnum;
                }
              }
            }
View Full Code Here

  SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) methodBinding.declaringClass;
  TypeDeclaration typeDeclaration = sourceTypeBinding.scope.referenceContext;
  BlockScope staticInitializerScope = typeDeclaration.staticInitializerScope;
  FieldDeclaration[] fieldDeclarations = typeDeclaration.fields;
  for (int i = methodBinding.startIndex, max = methodBinding.endIndex; i < max; i++) {
    FieldDeclaration fieldDecl = fieldDeclarations[i];
    if (fieldDecl.isStatic()) {
      if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
        fieldDecl.generateCode(staticInitializerScope, this);
      }
    }
  }
  return_();
}
View Full Code Here

        currentFileName = String.valueOf(x.compilationResult.fileName);

        if (x.fields != null) {
          // Process fields
          for (int i = 0, n = x.fields.length; i < n; ++i) {
            FieldDeclaration fieldDeclaration = x.fields[i];
            if (fieldDeclaration.isStatic()) {
              // clinit
              currentMethod = (JMethod) currentClass.methods.get(0);
              currentMethodScope = x.staticInitializerScope;
            } else {
              // init
View Full Code Here

  private boolean resolveFields(TreeLogger logger, String unitSource,
      JClassType type, FieldDeclaration[] jfields) {
    if (jfields != null) {
      for (int i = 0; i < jfields.length; i++) {
        FieldDeclaration jfield = jfields[i];
        if (!resolveField(logger, unitSource, type, jfield)) {
          return false;
        }
      }
    }
View Full Code Here

        }

        if (x.fields != null) {
          // Process fields
          for (int i = 0, n = x.fields.length; i < n; ++i) {
            FieldDeclaration fieldDeclaration = x.fields[i];
            if (fieldDeclaration.isStatic()) {
              // clinit
              currentMethod = currentClass.methods.get(0);
              currentMethodBody = (JMethodBody) currentMethod.getBody();
              currentMethodScope = x.staticInitializerScope;
            } else {
View Full Code Here

        method.traverse(sDeclarationConverter, (ClassScope) null);
        return root;
    }

    public Node convertFieldDeclaration(String fieldName, JavaCompilation compilation) {
      FieldDeclaration field = CompilationUtils.findField(compilation.getCompilationUnit(), fieldName);
      Node root = new Node(JavaEntityType.FIELD, fieldName);
      root.setEntity(new SourceCodeEntity(fieldName, JavaEntityType.FIELD, new SourceRange(
          field.declarationSourceStart,
          field.declarationSourceEnd)));
      sDeclarationConverter.initialize(root, compilation.getScanner());
      field.traverse(sDeclarationConverter, (MethodScope) null);
      return root;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.FieldDeclaration

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.