/**
  * Adds all visible methods to the given set in the specified type.
  *
  * @param type type to analyze
  * @param members set to add methods to
  * @param modifiers visibilities to consider
  */
 private void gatherVisibleMethods(IApiType type, Set<MethodKey> members, int modifiers) {
   IApiMethod[] methods = type.getMethods();
   for (int i = 0; i < methods.length; i++) {
     IApiMethod method = methods[i];
     if ((method.getModifiers() & modifiers) > 0
         && !method.isConstructor()
         && !method.isSynthetic()) {
       members.add(new MethodKey(type.getName(), method.getName(), method.getSignature(), false));
     }
   }
 }
示例#2
0
 /**
  * Returns a method descriptor with a resolved signature for the given method descriptor with an
  * unresolved signature.
  *
  * @param descriptor method to resolve
  * @return resolved method descriptor or the same method descriptor if unable to resolve
  * @exception CoreException if unable to resolve the method and a class file container was
  *     provided for this purpose
  */
 private IMethodDescriptor resolveMethod(IMethodDescriptor descriptor) throws CoreException {
   if (fContainer != null) {
     IReferenceTypeDescriptor type = descriptor.getEnclosingType();
     IApiTypeRoot classFile = fContainer.findTypeRoot(type.getQualifiedName());
     if (classFile != null) {
       IApiType structure = classFile.getStructure();
       if (structure != null) {
         IApiMethod[] methods = structure.getMethods();
         for (int i = 0; i < methods.length; i++) {
           IApiMethod method = methods[i];
           if (descriptor.getName().equals(method.getName())) {
             String signature = method.getSignature();
             String descriptorSignature = descriptor.getSignature().replace('/', '.');
             if (Signatures.matchesSignatures(
                 descriptorSignature, signature.replace('/', '.'))) {
               return descriptor.getEnclosingType().getMethod(method.getName(), signature);
             }
             String genericSignature = method.getGenericSignature();
             if (genericSignature != null) {
               if (Signatures.matchesSignatures(
                   descriptorSignature, genericSignature.replace('/', '.'))) {
                 return descriptor.getEnclosingType().getMethod(method.getName(), signature);
               }
             }
           }
         }
       }
     }
     throw new CoreException(
         new Status(
             IStatus.ERROR,
             ApiPlugin.PLUGIN_ID,
             MessageFormat.format(
                 "Unable to resolve method signature: {0}",
                 new String[] {descriptor.toString()}),
             null)); //$NON-NLS-1$
   }
   return descriptor;
 }