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

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


        case PARAMETER :
          VariableElementImpl variableElementImpl = (VariableElementImpl) e;
          binding = variableElementImpl._binding;
          if (binding instanceof FieldBinding) {
            FieldBinding fieldBinding = (FieldBinding) binding;
            FieldDeclaration fieldDeclaration = fieldBinding.sourceField();
            if (fieldDeclaration != null) {
              ReferenceBinding declaringClass = fieldBinding.declaringClass;
              if (declaringClass instanceof SourceTypeBinding) {
                SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
                TypeDeclaration typeDeclaration = (TypeDeclaration) sourceTypeBinding.scope.referenceContext();
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.isVarargs(), abstractMethod.parameters, false),
              new String(decl.name),
      },
      new String[] {
              new String(abstractMethod.selector),
              typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, 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

        break;
      case ENUM_CONSTANT :
      case FIELD :
        VariableElementImpl variableElementImpl = (VariableElementImpl) e;
        FieldBinding fieldBinding = (FieldBinding) variableElementImpl._binding;
        FieldDeclaration sourceField = fieldBinding.sourceField();
        if (sourceField != null) {
          javadoc = sourceField.javadoc;
          if (fieldBinding.declaringClass instanceof SourceTypeBinding) {
            SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) fieldBinding.declaringClass;
            referenceContext = sourceTypeBinding.scope.referenceContext;
View Full Code Here

}
public int lastMemberEnd() {
  int lastMemberEnd = this.typeDeclaration.bodyStart;

  if (this.fieldCount > 0) {
    FieldDeclaration lastField = this.fields[this.fieldCount - 1].fieldDeclaration;
    if (lastMemberEnd < lastField.declarationSourceEnd && lastField.declarationSourceEnd != 0) {
      lastMemberEnd = lastField.declarationSourceEnd;
    }
  }
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

    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

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.