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; }
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)); } }
/** * 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); } } }
@NotNull public List<Pair<PsiMethod, PsiSubstitutor>> getAllMethodsAndTheirSubstitutors() { return GrClassImplUtil.getAllMethodsAndTheirSubstitutors(this); }
@NotNull public List<Pair<PsiMethod, PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName( @NonNls String name, boolean checkBases) { return GrClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases); }
@NotNull public PsiMethod[] findMethodsByName(@NonNls String name, boolean checkBases) { return GrClassImplUtil.findCodeMethodsByName(this, name, checkBases); }
@NotNull public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) { return GrClassImplUtil.findCodeMethodsBySignature(this, patternMethod, checkBases); }
@Nullable public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) { return GrClassImplUtil.findMethodBySignature(this, patternMethod, checkBases); }
@Nullable public PsiField findFieldByName(@NonNls String name, boolean checkBases) { return GrClassImplUtil.findFieldByName(this, name, checkBases, true); }
@NotNull public PsiMethod[] getAllMethods() { return GrClassImplUtil.getAllMethods(this); }
@NotNull public PsiField[] getAllFields() { return GrClassImplUtil.getAllFields(this); }
@NotNull public PsiClassType[] getSuperTypes() { return GrClassImplUtil.getSuperTypes(this); }
@Nullable public PsiClass getSuperClass() { return GrClassImplUtil.getSuperClass(this); }