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

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


    allParameterAnnotations = new AnnotationBinding[length][];
    // forward reference to method, where param annotations have not yet been associated to method
    if (this.declaringClass instanceof SourceTypeBinding) {
      SourceTypeBinding sourceType = (SourceTypeBinding) this.declaringClass;
      if (sourceType.scope != null) {
        AbstractMethodDeclaration methodDecl = sourceType.scope.referenceType().declarationOf(this);
        for (int i = 0; i < length; i++) {
          Argument argument = methodDecl.arguments[i];
          if (argument.annotations != null) {
            ASTNode.resolveAnnotations(methodDecl.scope, argument.annotations, argument.binding);
            allParameterAnnotations[i] = argument.binding.getAnnotations();
View Full Code Here


  buffer.getChars(0, nameLength, this.signature, 0);

  return this.signature;
}
public final int sourceEnd() {
  AbstractMethodDeclaration method = sourceMethod();
  if (method == null) {
    if (this.declaringClass instanceof SourceTypeBinding)
      return ((SourceTypeBinding) this.declaringClass).sourceEnd();
    return 0;
  }
View Full Code Here

    if (this == methods[i].binding)
      return methods[i];
  return null;
}
public final int sourceStart() {
  AbstractMethodDeclaration method = sourceMethod();
  if (method == null) {
    if (this.declaringClass instanceof SourceTypeBinding)
      return ((SourceTypeBinding) this.declaringClass).sourceStart();
    return 0;
  }
View Full Code Here

      if (typeBinding.isInterface()) {
        // we cannot create problem methods for an interface. So we have to generate a clinit
        // which should contain all the problem
        classFile.addProblemClinit(problemsCopy);
        for (int i = 0, length = methodDecls.length; i < length; i++) {
          AbstractMethodDeclaration methodDecl = methodDecls[i];
          MethodBinding method = methodDecl.binding;
          if (method == null || method.isConstructor()) continue;
          classFile.addAbstractMethod(methodDecl, method);
        }
      } else {
        for (int i = 0, length = methodDecls.length; i < length; i++) {
          AbstractMethodDeclaration methodDecl = methodDecls[i];
          MethodBinding method = methodDecl.binding;
          if (method == null) continue;
          if (method.isConstructor()) {
            classFile.addProblemConstructor(methodDecl, method, problemsCopy);
          } else if (method.isAbstract()) {
View Full Code Here

      this.contents[this.contentsOffset++] = (byte) (signatureIndex >> 8);
      this.contents[this.contentsOffset++] = (byte) signatureIndex;
      attributeNumber++;
    }
    if (this.targetJDK >= ClassFileConstants.JDK1_5) {
      AbstractMethodDeclaration methodDeclaration = methodBinding.sourceMethod();
      if (methodDeclaration != null) {
        Annotation[] annotations = methodDeclaration.annotations;
        if (annotations != null) {
          attributeNumber += generateRuntimeAnnotations(annotations);
        }
View Full Code Here

    this.tagBits |= TagBits.LocalTypeMask;
  }
  this.enclosingCase = switchCase;
  this.sourceStart = typeDeclaration.sourceStart;
  MethodScope methodScope = scope.enclosingMethodScope();
  AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod();
  if (methodDeclaration != null) {
    this.enclosingMethod = methodDeclaration.binding;
  }
}
View Full Code Here

    for (int i = 0, length = this.methods.length; i < length; i++) {
      MethodBinding method = resolvedMethods[i];
      if (method == null)
        continue;
      char[] selector = method.selector;
      AbstractMethodDeclaration methodDecl = null;
      nextSibling: for (int j = i + 1; j < length; j++) {
        MethodBinding method2 = resolvedMethods[j];
        if (method2 == null)
          continue nextSibling;
        if (!CharOperation.equals(selector, method2.selector))
          break nextSibling; // methods with same selector are contiguous

        if (complyTo15 && method.returnType != null && method2.returnType != null) {
          // 8.4.2, for collision to be detected between m1 and m2:
          // signature(m1) == signature(m2) i.e. same arity, same type parameter count, can be substituted
          // signature(m1) == erasure(signature(m2)) or erasure(signature(m1)) == signature(m2)
          TypeBinding[] params1 = method.parameters;
          TypeBinding[] params2 = method2.parameters;
          int pLength = params1.length;
          if (pLength != params2.length)
            continue nextSibling;

          TypeVariableBinding[] vars = method.typeVariables;
          TypeVariableBinding[] vars2 = method2.typeVariables;
          boolean equalTypeVars = vars == vars2;
          MethodBinding subMethod = method2;
          if (!equalTypeVars) {
            MethodBinding temp = method.computeSubstitutedMethod(method2, this.scope.environment());
            if (temp != null) {
              equalTypeVars = true;
              subMethod = temp;
            }
          }
          boolean equalParams = method.areParametersEqual(subMethod);
          if (equalParams && equalTypeVars) {
            // duplicates regardless of return types
          } else if ((complyTo17 || method.returnType.erasure() == subMethod.returnType.erasure())
            && (equalParams || method.areParameterErasuresEqual(method2))) {
            // with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
            // we now ignore return types when detecting duplicates, just as we did before 1.5
            // name clash for sure if not duplicates, report as duplicates
            // FYI for now we will only make this change when compliance is set to 1.7 or higher
          } else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) {
            // type variables are different so we can distinguish between methods
            continue nextSibling;
          } else if (pLength > 0) {
            // check to see if the erasure of either method is equal to the other
            int index = pLength;
            for (; --index >= 0;) {
              if (params1[index] != params2[index].erasure())
                break;
              if (params1[index] == params2[index]) {
                TypeBinding type = params1[index].leafComponentType();
                if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) {
                  index = pLength; // handle comparing identical source types like X<T>... its erasure is itself BUT we need to answer false
                  break;
                }
              }
            }
            if (index >= 0 && index < pLength) {
              for (index = pLength; --index >= 0;)
                if (params1[index].erasure() != params2[index])
                  break;
            }
            if (index >= 0)
              continue nextSibling;
          }
        } else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case
          continue nextSibling;
        }
        boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES));
        // report duplicate
        boolean removeMethod2 = true;
        if (methodDecl == null) {
          methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special
          if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method
            boolean removeMethod = method.returnType == null && method2.returnType != null;
            if (isEnumSpecialMethod) {
              this.scope.problemReporter().duplicateEnumSpecialMethod(this, methodDecl);
              // remove user defined methods & keep the synthetic
              removeMethod = true;
            } else {
              this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2));
            }
            if (removeMethod) {
              removeMethod2 = false;
              methodDecl.binding = null;
              // do not alter original method array until resolution is over, due to reentrance (143259)
              if (resolvedMethods == this.methods)
                System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length);
              resolvedMethods[i] = null;
              failed++;
            }
          }
        }
        AbstractMethodDeclaration method2Decl = method2.sourceMethod();
        if (method2Decl != null && method2Decl.binding != null) { // ensure its a valid user defined method
          if (isEnumSpecialMethod) {
            this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl);
            removeMethod2 = true;
          } else {
View Full Code Here

  if (isViewedAsDeprecated() && !method.isDeprecated())
    method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
  if (hasRestrictedAccess())
    method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;

  AbstractMethodDeclaration methodDecl = method.sourceMethod();
  if (methodDecl == null) return null; // method could not be resolved in previous iteration

  TypeParameter[] typeParameters = methodDecl.typeParameters();
  if (typeParameters != null) {
    methodDecl.scope.connectTypeVariables(typeParameters, true);
    // Perform deferred bound checks for type variables (only done after type variable hierarchy is connected)
    for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++)
      typeParameters[i].checkBounds(methodDecl.scope);
View Full Code Here

        case METHOD :
          ExecutableElementImpl executableElementImpl = (ExecutableElementImpl) e;
          Binding binding = executableElementImpl._binding;
          if (binding instanceof MethodBinding) {
            MethodBinding methodBinding = (MethodBinding) binding;
            AbstractMethodDeclaration sourceMethod = methodBinding.sourceMethod();
            if (sourceMethod != null) {
              referenceContext = sourceMethod;
              elementAnnotations = sourceMethod.annotations;
              startPosition = sourceMethod.sourceStart;
              endPosition = sourceMethod.sourceEnd;
View Full Code Here

      && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
    id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
  } else {
    id = IProblem.IncompatibleReturnType;
  }
  AbstractMethodDeclaration method = currentMethod.sourceMethod();
  int sourceStart = 0;
  int sourceEnd = 0;
  if (method == null) {
    if (declaringClass instanceof SourceTypeBinding) {
      SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
      sourceStart = sourceTypeBinding.sourceStart();
      sourceEnd = sourceTypeBinding.sourceEnd();
    }
  } else if (method.isConstructor()){
    sourceStart = method.sourceStart;
    sourceEnd = method.sourceEnd;
  } else {
    TypeReference returnType = ((MethodDeclaration) method).returnType;
    sourceStart = returnType.sourceStart;
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.