コード例 #1
0
ファイル: MethodBinding.java プロジェクト: lyestoo/eclipse
  /* (non-Javadoc)
   * @see IMethodBinding#overrides(IMethodBinding)
   */
  public boolean overrides(IMethodBinding overridenMethod) {
    org.eclipse.jdt.internal.compiler.lookup.MethodBinding overridenCompilerBinding =
        ((MethodBinding) overridenMethod).binding;
    if (this.binding == overridenCompilerBinding) return false;
    if (!CharOperation.equals(this.binding.selector, overridenCompilerBinding.selector))
      return false;
    ReferenceBinding match =
        this.binding.declaringClass.findSuperTypeWithSameErasure(
            overridenCompilerBinding.declaringClass);
    if (match == null) return false;

    org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] superMethods = match.methods();
    for (int i = 0, length = superMethods.length; i < length; i++) {
      if (superMethods[i].original() == overridenCompilerBinding) {
        LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment();
        if (lookupEnvironment == null) return false;
        MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
        return methodVerifier.doesMethodOverride(this.binding, superMethods[i]);
      }
    }
    return false;
  }
コード例 #2
0
 /* collect matching methods from one supertype. */
 private void collectOverriddenMethods(
     MethodBinding original,
     char[] selector,
     int suggestedParameterLength,
     ReferenceBinding superType,
     Set ifcsSeen,
     List result) {
   MethodBinding[] ifcMethods = superType.getMethods(selector, suggestedParameterLength);
   int length = ifcMethods.length;
   boolean added = false;
   for (int i = 0; i < length; i++) {
     MethodBinding currentMethod = ifcMethods[i];
     if (currentMethod.isStatic()) continue;
     if (MethodVerifier.doesMethodOverride(original, currentMethod, this.environment)) {
       result.add(currentMethod);
       added =
           true; // when overriding one or more methods from superType don't traverse to transitive
                 // superTypes
     }
   }
   if (!added)
     findAllOverriddenMethods(
         original, selector, suggestedParameterLength, superType, ifcsSeen, result);
 }