コード例 #1
0
 public boolean processDeclarations(
     @NotNull PsiScopeProcessor processor,
     @NotNull ResolveState state,
     PsiElement lastParent,
     @NotNull PsiElement place) {
   return GrClassImplUtil.processDeclarations(this, processor, state, lastParent, place);
 }
 @Override
 public PsiType fun(GrSuperReferenceExpressionImpl ref) {
   final GrReferenceExpression qualifier = ref.getQualifier();
   if (qualifier == null) {
     GroovyPsiElement context =
         PsiTreeUtil.getParentOfType(ref, GrTypeDefinition.class, GroovyFileBase.class);
     if (context instanceof GrTypeDefinition) {
       final PsiClass superClass = ((GrTypeDefinition) context).getSuperClass();
       if (superClass != null) {
         return JavaPsiFacade.getInstance(ref.getProject())
             .getElementFactory()
             .createType(superClass);
       }
     } else if (context instanceof GroovyFileBase) {
       PsiClass scriptClass = ((GroovyFileBase) context).getScriptClass();
       if (scriptClass != null) {
         PsiClass superClass = scriptClass.getSuperClass();
         if (superClass != null) {
           return JavaPsiFacade.getInstance(ref.getProject())
               .getElementFactory()
               .createType(superClass);
         }
       }
       return GrClassImplUtil.getGroovyObjectType(ref);
     }
   } else {
     final PsiElement resolved = qualifier.resolve();
     if (resolved instanceof PsiClass) {
       return ref.getSuperType((PsiClass) resolved);
     }
   }
   return null;
 }
コード例 #3
0
  private static void collectMethods(
      PsiClass currentClass,
      PsiSubstitutor currentClassSubstitutor,
      boolean shouldProcessDeprecated,
      GrTypeDefinition classToDelegateTo,
      Collection<PsiMethod> collector,
      boolean keepParameterAnnotations) {
    final List<PsiMethod> methods;
    if (currentClass instanceof GrTypeDefinition) {
      methods = new ArrayList<PsiMethod>();
      GrClassImplUtil.collectMethodsFromBody((GrTypeDefinition) currentClass, methods);
    } else {
      methods = Arrays.asList(currentClass.getMethods());
    }

    for (PsiMethod method : methods) {
      if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) continue;
      if (overridesObjectOrGroovyObject(method)) continue;
      if (!shouldProcessDeprecated
          && PsiImplUtil.getAnnotation(method, CommonClassNames.JAVA_LANG_DEPRECATED) != null)
        continue;
      collector.add(
          generateDelegateMethod(
              method, classToDelegateTo, currentClassSubstitutor, keepParameterAnnotations));
    }
  }
コード例 #4
0
  /**
   * Adds all code methods of clazz add its super classes to signatures. Doesn't walk into
   * interfaces because all methods from them will be overloaded in any case. Besides Some of
   * interfaces came from delegates and they should be visited during the following processing.
   *
   * @param clazz current class
   * @param substitutor super class substitutor of clazz
   * @param signatures map to initialize
   * @param classes already visited classes
   */
  private static void initializeSignatures(
      PsiClass clazz,
      PsiSubstitutor substitutor,
      Map<MethodSignature, PsiMethod> signatures,
      Set<PsiClass> classes) {
    if (clazz.isInterface()) return;

    if (classes.add(clazz)) {
      final List<PsiMethod> methods;
      if (clazz instanceof GrTypeDefinition) {
        methods = new ArrayList<PsiMethod>();
        GrClassImplUtil.collectMethodsFromBody((GrTypeDefinition) clazz, methods);
      } else {
        methods = Arrays.asList(clazz.getMethods());
      }

      for (PsiMethod method : methods) {
        addMethodChecked(signatures, method, substitutor, null);
      }

      for (PsiClassType type : getSuperTypes(clazz)) {
        final PsiClassType.ClassResolveResult result = type.resolveGenerics();
        final PsiClass superClass = result.getElement();
        if (superClass == null) continue;
        final PsiSubstitutor superClassSubstitutor =
            TypeConversionUtil.getSuperClassSubstitutor(superClass, clazz, substitutor);
        initializeSignatures(superClass, superClassSubstitutor, signatures, classes);
      }
    }
  }
コード例 #5
0
 @NotNull
 public List<Pair<PsiMethod, PsiSubstitutor>> getAllMethodsAndTheirSubstitutors() {
   return GrClassImplUtil.getAllMethodsAndTheirSubstitutors(this);
 }
コード例 #6
0
 @NotNull
 public List<Pair<PsiMethod, PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(
     @NonNls String name, boolean checkBases) {
   return GrClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases);
 }
コード例 #7
0
 @NotNull
 public PsiMethod[] findMethodsByName(@NonNls String name, boolean checkBases) {
   return GrClassImplUtil.findCodeMethodsByName(this, name, checkBases);
 }
コード例 #8
0
 @NotNull
 public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) {
   return GrClassImplUtil.findCodeMethodsBySignature(this, patternMethod, checkBases);
 }
コード例 #9
0
 @Nullable
 public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) {
   return GrClassImplUtil.findMethodBySignature(this, patternMethod, checkBases);
 }
コード例 #10
0
 @Nullable
 public PsiField findFieldByName(@NonNls String name, boolean checkBases) {
   return GrClassImplUtil.findFieldByName(this, name, checkBases, true);
 }
コード例 #11
0
 @NotNull
 public PsiMethod[] getAllMethods() {
   return GrClassImplUtil.getAllMethods(this);
 }
コード例 #12
0
 @NotNull
 public PsiField[] getAllFields() {
   return GrClassImplUtil.getAllFields(this);
 }
コード例 #13
0
 @NotNull
 public PsiClassType[] getSuperTypes() {
   return GrClassImplUtil.getSuperTypes(this);
 }
コード例 #14
0
 @Nullable
 public PsiClass getSuperClass() {
   return GrClassImplUtil.getSuperClass(this);
 }