Examples of IBinaryMethod


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  IBinaryMethod[] methods = typeInfo.getMethods();
  if (methods == null) {
    return;
  }
  for (int i = 0, methodCount = methods.length; i < methodCount; i++) {
    IBinaryMethod methodInfo = methods[i];
    // TODO (jerome) filter out synthetic members
    //                        indexer should not index them as well
    // if ((methodInfo.getModifiers() & IConstants.AccSynthetic) != 0) continue; // skip synthetic
    char[] signature = methodInfo.getGenericSignature();
    if (signature == null) signature = methodInfo.getMethodDescriptor();
    String[] pNames = null;
    try {
      pNames = Signature.getParameterTypes(new String(signature));
    } catch (IllegalArgumentException e) {
      // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature)
      signature = methodInfo.getMethodDescriptor();
      pNames = Signature.getParameterTypes(new String(signature));
    }
    char[][] paramNames= new char[pNames.length][];
    for (int j= 0; j < pNames.length; j++) {
      paramNames[j]= pNames[j].toCharArray();
    }
    char[][] parameterTypes = ClassFile.translatedNames(paramNames);
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    String selector = new String(methodInfo.getSelector());
    if (methodInfo.isConstructor()) {
      selector =type.getElementName();
    }
    selector =  manager.intern(selector);
    for (int j= 0; j < pNames.length; j++) {
      pNames[j]= manager.intern(new String(parameterTypes[j]));
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod

    IBinaryMethod[] existingMs = existingType.binMethods;
    if (newMethods.length != existingMs.length) {
      return true;
    }
    new_method_loop: for (int i = 0; i < newMethods.length; i++) {
      IBinaryMethod method = newMethods[i];
      char[] methodName = method.getSelector();
      for (int j = 0; j < existingMs.length; j++) {
        if (CharOperation.equals(existingMs[j].getSelector(), methodName)) {
          // candidate match
          if (!CharOperation.equals(method.getMethodDescriptor(), existingMs[j].getMethodDescriptor())) {
            // ok, the descriptors don't match, but is this a funky ctor on a non-static inner
            // type?
            // boolean mightBeOK =
            // skippableDescriptorPrefix!=null && // set for inner types
            // CharOperation.equals(methodName,NameMangler.INIT) && // ctor
            // CharOperation.prefixEquals(skippableDescriptorPrefix,method.getMethodDescriptor()); // checking for
            // prefix on the descriptor
            // if (mightBeOK) {
            // // OK, so the descriptor starts something like '(Lpkg/Foo;' - we now may need to look at the rest of the
            // // descriptor if it takes >1 parameter.
            // // eg. could be (Lpkg/C;Ljava/lang/String;) where the skippablePrefix is (Lpkg/C;
            // char [] md = method.getMethodDescriptor();
            // char[] remainder = CharOperation.subarray(md, skippableDescriptorPrefix.length, md.length);
            // if (CharOperation.equals(remainder,BRACKET_V)) continue new_method_loop; // no other parameters to worry
            // about
            // char[] comparableSig = CharOperation.subarray(existingMethods[j].signature, 1,
            // existingMethods[j].signature.length);
            // boolean match = CharOperation.equals(comparableSig, remainder);
            // if (match) continue new_method_loop;
            // }
            continue; // might be overloading
          } else {
            // matching sigs
            IBinaryMethod existing = existingMs[j];
            if (!modifiersEqual(method.getModifiers(), existing.getModifiers())) {
              return true;
            }

            if (exceptionClausesDiffer(existing, method)) {
              return true;
            }

            char[] existingGSig = existing.getGenericSignature();
            char[] methodGSig = method.getGenericSignature();
            if ((existingGSig == null && methodGSig != null) || (existingGSig != null && methodGSig == null)) {
              return true;
            }
            if (existingGSig != null) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

   
    String methodName = method.getElementName();
    if (method.isConstructor()) {
      methodName = typeQualifiedName;
    }
    IBinaryMethod info = (IBinaryMethod) method.getElementInfo();

    char[] genericSignature = info.getGenericSignature();
    String anchor = null;
    if (genericSignature != null) {
      genericSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
      anchor = Util.toAnchor(0, genericSignature, methodName, Flags.isVarargs(method.getFlags()));
      if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, method));
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

public boolean equals(Object o) {
  if (!(o instanceof BinaryMethod)) return false;
  return super.equals(o) && Util.equalArraysOrNull(getErasedParameterTypes(), ((BinaryMethod)o).getErasedParameterTypes());
}
public IAnnotation[] getAnnotations() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
  return getAnnotations(binaryAnnotations, info.getTagBits());
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
  return getAnnotations(binaryAnnotations, info.getTagBits());
}
public ILocalVariable[] getParameters() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  int length = this.parameterTypes.length;
  if (length == 0) {
    return LocalVariable.NO_LOCAL_VARIABLES;
  }
  ILocalVariable[] localVariables = new ILocalVariable[length];
  char[][] argumentNames = info.getArgumentNames();
  if (argumentNames == null || argumentNames.length < length) {
    argumentNames = new char[length][];
    for (int j = 0; j < length; j++) {
      argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
    }
  }
  for (int i= 0; i < length; i++) {
    LocalVariable localVariable = new LocalVariable(
        this,
        new String(argumentNames[i]),
        0,
        -1,
        0,
        -1,
        this.parameterTypes[i],
        null,
        -1,
        true);
    localVariables[i] = localVariable;
    IAnnotation[] annotations = getAnnotations(localVariable, info.getParameterAnnotations(i), info.getTagBits());
    localVariable.annotations = annotations;
  }
  return localVariables;
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

  }
  System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
  return annotations;
}
public IMemberValuePair getDefaultValue() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  Object defaultValue = info.getDefaultValue();
  if (defaultValue == null)
    return null;
  MemberValuePair memberValuePair = new MemberValuePair(getElementName());
  memberValuePair.value = Util.getAnnotationMemberValue(this, memberValuePair, defaultValue);
  return memberValuePair;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

/*
* @see IMethod
*/
public String[] getExceptionTypes() throws JavaModelException {
  if (this.exceptionTypes == null) {
    IBinaryMethod info = (IBinaryMethod) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature != null) {
      char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
      this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature));
    }
    if (this.exceptionTypes == null || this.exceptionTypes.length == 0) {
      char[][] eTypeNames = info.getExceptionTypeNames();
      if (eTypeNames == null || eTypeNames.length == 0) {
        this.exceptionTypes = CharOperation.NO_STRINGS;
      } else {
        eTypeNames = ClassFile.translatedNames(eTypeNames);
        this.exceptionTypes = new String[eTypeNames.length];
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

}
/*
* @see IMember
*/
public int getFlags() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  return info.getModifiers();
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

      return this.parameterNames = names;
    }
  }

  // try to see if we can retrieve the names from the attached javadoc
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  // https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
  // Use Signature#getParameterCount() only if the argument names are not already available.
  int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
  if (this.isConstructor()) {
    final IType declaringType = this.getDeclaringType();
    if (declaringType.isMember()
        && !Flags.isStatic(declaringType.getFlags())) {
      paramCount--; // remove synthetic argument from constructor param count
    }
  }

  if (paramCount != 0) {
    // don't try to look for javadoc for synthetic methods
    int modifiers = getFlags();
    if ((modifiers & ClassFileConstants.AccSynthetic) != 0) {
      return this.parameterNames = getRawParameterNames(paramCount);
    }
    JavadocContents javadocContents = null;
    IType declaringType = getDeclaringType();
    PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(getJavaProject().getProject());
    synchronized (projectInfo.javadocCache) {
      javadocContents = (JavadocContents) projectInfo.javadocCache.get(declaringType);
      if (javadocContents == null) {
        projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC);
      }
    }
   
    String methodDoc = null;
    if (javadocContents == null) {
      long timeOut = 50; // default value
      try {
        String option = getJavaProject().getOption(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, true);
        if (option != null) {
          timeOut = Long.parseLong(option);
        }
      } catch(NumberFormatException e) {
        // ignore
      }
      if (timeOut == 0) {
        // don't try to fetch the values and don't cache either (https://bugs.eclipse.org/bugs/show_bug.cgi?id=329671)
        return getRawParameterNames(paramCount);
      }
      final class ParametersNameCollector {
        String javadoc;
        public void setJavadoc(String s) {
          this.javadoc = s;
        }
        public String getJavadoc() {
          return this.javadoc;
        }
      }
      /*
       * The declaring type is not in the cache yet. The thread wil retrieve the javadoc contents
       */
      final ParametersNameCollector nameCollector = new ParametersNameCollector();
      Thread collect = new Thread() {
        public void run() {
          try {
            // this call has a side-effect on the per project info cache
            nameCollector.setJavadoc(BinaryMethod.this.getAttachedJavadoc(null));
          } catch (JavaModelException e) {
            // ignore
          }
          synchronized(nameCollector) {
            nameCollector.notify();
          }
        }
      };
      collect.start();
      synchronized(nameCollector) {
        try {
          nameCollector.wait(timeOut);
        } catch (InterruptedException e) {
          // ignore
        }
      }
      methodDoc = nameCollector.getJavadoc();
    } else if (javadocContents != BinaryType.EMPTY_JAVADOC){
      // need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type
      try {
        methodDoc = javadocContents.getMethodDoc(this);
      } catch(JavaModelException e) {
        javadocContents = null;
      }
    }
    if (methodDoc != null) {
      final int indexOfOpenParen = methodDoc.indexOf('(');
      if (indexOfOpenParen != -1) {
        final int indexOfClosingParen = methodDoc.indexOf(')', indexOfOpenParen);
        if (indexOfClosingParen != -1) {
          final char[] paramsSource =
            CharOperation.replace(
              methodDoc.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(),
              "&nbsp;".toCharArray(), //$NON-NLS-1$
              new char[] {' '});
          final char[][] params = splitParameters(paramsSource, paramCount);
          final int paramsLength = params.length;
          String[] names = new String[paramsLength];
          for (int i = 0; i < paramsLength; i++) {
            final char[] param = params[i];
            int indexOfSpace = CharOperation.lastIndexOf(' ', param);
            if (indexOfSpace != -1) {
              names[i] = String.valueOf(param, indexOfSpace + 1, param.length - indexOfSpace -1);
            } else {
              names[i] = "arg" + i; //$NON-NLS-1$
            }
          }
          return this.parameterNames = names;
        }
      }
    }
    // let's see if we can retrieve them from the debug infos
    char[][] argumentNames = info.getArgumentNames();
    if (argumentNames != null && argumentNames.length == paramCount) {
      String[] names = new String[paramCount];
      for (int i = 0; i < paramCount; i++) {
        names[i] = new String(argumentNames[i]);
      }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.env.IBinaryMethod

* @see IMethod#getTypeParameterSignatures()
* @since 3.0
* @deprecated
*/
public String[] getTypeParameterSignatures() throws JavaModelException {
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  char[] genericSignature = info.getGenericSignature();
  if (genericSignature == null)
    return CharOperation.NO_STRINGS;
  char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
  char[][] typeParams = Signature.getTypeParameters(dotBasedSignature);
  return CharOperation.toStrings(typeParams);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.