use of com.intellij.psi.util.MethodSignature in project intellij-community by JetBrains.
the class StubGenerator method collectMethods.
@Override
public Collection<PsiMethod> collectMethods(PsiClass typeDefinition) {
List<PsiMethod> methods = new ArrayList<>();
for (PsiMethod method : typeDefinition.getMethods()) {
if (method instanceof DelegatedMethod) {
PsiMethod prototype = ((DelegatedMethod) method).getPrototype();
PsiClass aClass = prototype.getContainingClass();
if (prototype.hasModifierProperty(PsiModifier.FINAL) && aClass != null && typeDefinition.isInheritor(aClass, true)) {
//skip final super methods
continue;
}
}
methods.add(method);
}
boolean isClass = !typeDefinition.isInterface() && !typeDefinition.isAnnotationType() && !typeDefinition.isEnum() && !(typeDefinition instanceof GroovyScriptClass);
if (isClass) {
final Collection<MethodSignature> toOverride = OverrideImplementExploreUtil.getMethodSignaturesToOverride(typeDefinition);
for (MethodSignature signature : toOverride) {
if (!(signature instanceof MethodSignatureBackedByPsiMethod))
continue;
final PsiMethod method = ((MethodSignatureBackedByPsiMethod) signature).getMethod();
final PsiClass baseClass = method.getContainingClass();
if (baseClass == null)
continue;
final String qname = baseClass.getQualifiedName();
if (GroovyCommonClassNames.GROOVY_OBJECT.equals(qname) || GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT.equals(qname) || method.hasModifierProperty(PsiModifier.ABSTRACT) && typeDefinition.isInheritor(baseClass, true)) {
if (method.isConstructor())
continue;
methods.add(mirrorMethod(typeDefinition, method, baseClass, signature.getSubstitutor()));
}
}
final Collection<MethodSignature> toImplement = OverrideImplementExploreUtil.getMethodSignaturesToImplement(typeDefinition);
for (MethodSignature signature : toImplement) {
if (!(signature instanceof MethodSignatureBackedByPsiMethod))
continue;
final PsiMethod resolved = ((MethodSignatureBackedByPsiMethod) signature).getMethod();
final PsiClass baseClass = resolved.getContainingClass();
if (baseClass == null)
continue;
if (!GroovyCommonClassNames.GROOVY_OBJECT.equals(baseClass.getQualifiedName()))
continue;
methods.add(mirrorMethod(typeDefinition, resolved, baseClass, signature.getSubstitutor()));
}
}
return methods;
}
Aggregations