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

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


    this.superTypeNames[this.nestedTypeIndex++] = implicitSuperclassName;
  }
  while ((fieldIndex < fieldCounter)
      || (memberTypeIndex < memberTypeCounter)
      || (methodIndex < methodCounter)) {
    FieldDeclaration nextFieldDeclaration = null;
    AbstractMethodDeclaration nextMethodDeclaration = null;
    TypeDeclaration nextMemberDeclaration = null;

    int position = Integer.MAX_VALUE;
    int nextDeclarationType = -1;
View Full Code Here


    type.sourceEnd());
}
public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
  if (type.isEnum() && type.isLocalType()) {
    FieldBinding field = type.scope.enclosingMethodScope().initializedField;
    FieldDeclaration decl = field.sourceField();
    String[] arguments = new String[] {new String(decl.name), new String(methodDecl.selector)};
    this.handle(
      IProblem.AbstractMethodInEnum,
      arguments,
      arguments,
View Full Code Here

  }
}
public void abstractMethodInConcreteClass(SourceTypeBinding type) {
  if (type.isEnum() && type.isLocalType()) {
    FieldBinding field = type.scope.enclosingMethodScope().initializedField;
    FieldDeclaration decl = field.sourceField();
    String[] arguments = new String[] {new String(decl.name)};
    this.handle(
      IProblem.EnumConstantCannotDefineAbstractMethod,
      arguments,
      arguments,
      decl.sourceStart(),
      decl.sourceEnd());
  } else {
    String[] arguments = new String[] {new String(type.sourceName())};
    this.handle(
      IProblem.AbstractMethodsInConcreteClass,
      arguments,
View Full Code Here

  }
}
public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
  if (type.isEnum() && type.isLocalType()) {
    FieldBinding field = type.scope.enclosingMethodScope().initializedField;
    FieldDeclaration decl = field.sourceField();
    this.handle(
      // Must implement the inherited abstract method %1
      // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
      IProblem.EnumConstantMustImplementAbstractMethod,
      new String[] {
              new String(abstractMethod.selector),
              typesAsString(abstractMethod, false),
              new String(decl.name),
      },
      new String[] {
              new String(abstractMethod.selector),
              typesAsString(abstractMethod, true),
              new String(decl.name),
      },
      decl.sourceStart(),
      decl.sourceEnd());
  } else {
    this.handle(
      // Must implement the inherited abstract method %1
      // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
      IProblem.AbstractMethodMustBeImplemented,
View Full Code Here

  private boolean resolveFields(TreeLogger logger, char[] 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 = (JMethod) currentClass.methods.get(0);
              currentMethodBody = (JMethodBody) currentMethod.getBody();
              currentMethodScope = x.staticInitializerScope;
            } else {
View Full Code Here

    this.superTypeNames[this.nestedTypeIndex++] = implicitSuperclassName;
  }
  while ((fieldIndex < fieldCounter)
      || (memberTypeIndex < memberTypeCounter)
      || (methodIndex < methodCounter)) {
    FieldDeclaration nextFieldDeclaration = null;
    AbstractMethodDeclaration nextMethodDeclaration = null;
    TypeDeclaration nextMemberDeclaration = null;

    int position = Integer.MAX_VALUE;
    int nextDeclarationType = -1;
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) {
        if (sourceType.isInterface())
          problemReporter().interfaceCannotHaveInitializers(sourceType, field);
      } 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

      FieldBinding originalField = original();
      if (originalField.declaringClass instanceof SourceTypeBinding) {
        SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass;
        if (sourceType.scope != null) {
          TypeDeclaration typeDecl = sourceType.scope.referenceContext;
          FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField);
          MethodScope initScope = originalField.isStatic() ? typeDecl.staticInitializerScope : typeDecl.initializerScope;
          boolean old = initScope.insideTypeAnnotation;
          try {
            initScope.insideTypeAnnotation = false;
            fieldDecl.resolve(initScope); //side effect on binding
          } finally {
            initScope.insideTypeAnnotation = old;
          }
          fieldConstant = originalField.constant == null ? Constant.NotAConstant : originalField.constant;
        } else {
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.