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

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


          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.getMethods().get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) (method.getEnclosingType().isExternal() ? null :
          method.getBody());
View Full Code Here


   * @see org.eclipse.jdt.core.dom.BindingResolver#resolveMember(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration)
   */
  IMethodBinding resolveMember(AnnotationTypeMemberDeclaration declaration) {
    Object oldNode = this.newAstToOldAst.get(declaration);
    if (oldNode instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode;
      IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
      if (methodBinding == null) {
        return null;
      }
      this.bindingsToAstNodes.put(methodBinding, declaration);
View Full Code Here

   * Method declared on BindingResolver.
   */
  synchronized IMethodBinding resolveMethod(MethodDeclaration method) {
    Object oldNode = this.newAstToOldAst.get(method);
    if (oldNode instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode;
      IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
      if (methodBinding == null) {
        return null;
      }
      this.bindingsToAstNodes.put(methodBinding, method);
View Full Code Here

          }
          return null;
        }
      }
    } else if (node instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
      IMethodBinding method = getMethodBinding(methodDeclaration.binding);
      if (method == null) return null;
      return method.getReturnType();
    } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
      org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
View Full Code Here

        if (typeBinding != null) {
          return typeBinding.getPackage();
        }
      }
    } else if (node instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
      IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
      if (methodBinding != null) {
        return methodBinding;
      }
    } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
View Full Code Here

    int fieldIndex = 0, fieldCount = (typeDeclaration.fields == null) ? 0 : typeDeclaration.fields.length;
    FieldDeclaration field = fieldCount == 0 ? null : typeDeclaration.fields[fieldIndex];
    int fieldStart = field == null ? Integer.MAX_VALUE : field.declarationSourceStart;

    int methodIndex = 0, methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
    AbstractMethodDeclaration method = methodCount == 0 ? null : typeDeclaration.methods[methodIndex];
    int methodStart = method == null ? Integer.MAX_VALUE : method.declarationSourceStart;

    int typeIndex = 0, typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;
    TypeDeclaration type = typeCount == 0 ? null : typeDeclaration.memberTypes[typeIndex];
    int typeStart = type == null ? Integer.MAX_VALUE : type.declarationSourceStart;

    final int memberLength = fieldCount+methodCount+typeCount;
    ASTNode[] members = new ASTNode[memberLength];
    if (memberLength != 0) {
      int index = 0;
      int previousFieldStart = -1;
      do {
        if (fieldStart < methodStart && fieldStart < typeStart) {
          if (field.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
            // filter out enum constants
            previousFieldStart = fieldStart;
            if (++fieldIndex < fieldCount) { // find next field if any
              fieldStart = (field = typeDeclaration.fields[fieldIndex]).declarationSourceStart;
            } else {
              fieldStart = Integer.MAX_VALUE;
            }
            continue;
          }
          // next member is a field
          if (fieldStart == previousFieldStart){
            ASTNode previousMember = members[index - 1];
            if (previousMember instanceof MultiFieldDeclaration) {
              MultiFieldDeclaration multiField = (MultiFieldDeclaration) previousMember;
              int length = multiField.declarations.length;
              System.arraycopy(multiField.declarations, 0, multiField.declarations=new FieldDeclaration[length+1], 0, length);
              multiField.declarations[length] = field;
            } else {
              FieldDeclaration fieldDeclaration = (FieldDeclaration)previousMember;
              final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration(new FieldDeclaration[]{ fieldDeclaration, field});
              multiFieldDeclaration.annotations = fieldDeclaration.annotations;
              members[index - 1] = multiFieldDeclaration;
            }
          } else {
            members[index++] = field;
          }
          previousFieldStart = fieldStart;
          if (++fieldIndex < fieldCount) { // find next field if any
            fieldStart = (field = typeDeclaration.fields[fieldIndex]).declarationSourceStart;
          } else {
            fieldStart = Integer.MAX_VALUE;
          }
        } else if (methodStart < fieldStart && methodStart < typeStart) {
          // next member is a method
          if (!method.isDefaultConstructor() && !method.isClinit()) {
            members[index++] = method;
          }
          if (++methodIndex < methodCount) { // find next method if any
            methodStart = (method = typeDeclaration.methods[methodIndex]).declarationSourceStart;
          } else {
View Full Code Here

    int methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
    int typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;

    if (methodCount <= 2) {
      for (int i = 0, max = methodCount; i < max; i++) {
        final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration.methods[i];
        if (abstractMethodDeclaration.isDefaultConstructor()) {
          methodCount--;
        } else if (abstractMethodDeclaration.isClinit()) {
          methodCount--;
        }
      }
    }
    final int memberLength = fieldCount + methodCount+typeCount;
View Full Code Here

    int methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
    int typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;

    if (methodCount <= 2) {
      for (int i = 0, max = methodCount; i < max; i++) {
        final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration.methods[i];
        if (abstractMethodDeclaration.isDefaultConstructor()) {
          methodCount--;
        } else if (abstractMethodDeclaration.isClinit()) {
          methodCount--;
        }
      }
    }
    final int memberLength = fieldCount + methodCount + typeCount;
View Full Code Here

        abstractMethodsOnly = true;
      // We generate a clinit which contains all the problems, since we may not be able to generate problem methods (< 1.8) and problem constructors (all levels).
      classFile.addProblemClinit(problemsCopy);
    }
    for (int i = 0, length = methodDecls.length; i < length; i++) {
      AbstractMethodDeclaration methodDecl = methodDecls[i];
      MethodBinding method = methodDecl.binding;
      if (method == null) continue;
      if (abstractMethodsOnly) {
        method.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract;
      }
View Full Code Here

          abstractMethodsOnly = true;
        // We generate a clinit which contains all the problems, since we may not be able to generate problem methods (< 1.8) and problem constructors (all levels).
        classFile.addProblemClinit(problemsCopy);
      }
      for (int i = 0, length = methodDecls.length; i < length; i++) {
        AbstractMethodDeclaration methodDecl = methodDecls[i];
        MethodBinding method = methodDecl.binding;
        if (method == null) continue;
        if (abstractMethodsOnly) {
          method.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract;
        }
View Full Code Here

TOP

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

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.