use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause in project intellij-community by JetBrains.
the class GrMemberInfoStorage method buildSubClassesMap.
@Override
protected void buildSubClassesMap(PsiClass aClass) {
if (aClass instanceof GrTypeDefinition) {
final GrExtendsClause extendsList = ((GrTypeDefinition) aClass).getExtendsClause();
if (extendsList != null) {
buildSubClassesMapForList(extendsList.getReferencedTypes(), (GrTypeDefinition) aClass);
}
final GrImplementsClause implementsList = ((GrTypeDefinition) aClass).getImplementsClause();
if (implementsList != null) {
buildSubClassesMapForList(implementsList.getReferencedTypes(), (GrTypeDefinition) aClass);
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause in project intellij-community by JetBrains.
the class GroovyTestGenerator method addSuperClass.
private static void addSuperClass(@NotNull GrTypeDefinition targetClass, @NotNull Project project, @Nullable String superClassName) throws IncorrectOperationException {
if (superClassName == null)
return;
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
PsiClass superClass = findClass(project, superClassName);
GrCodeReferenceElement superClassRef;
if (superClass != null) {
superClassRef = factory.createCodeReferenceElementFromClass(superClass);
} else {
superClassRef = factory.createCodeReferenceElementFromText(superClassName);
}
GrExtendsClause extendsClause = targetClass.getExtendsClause();
if (extendsClause == null) {
extendsClause = (GrExtendsClause) targetClass.addAfter(factory.createExtendsClause(), targetClass.getNameIdentifierGroovy());
}
extendsClause.add(superClassRef);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause in project intellij-community by JetBrains.
the class GrHighlightUtil method getClassHeaderTextRange.
public static TextRange getClassHeaderTextRange(GrTypeDefinition clazz) {
final GrModifierList modifierList = clazz.getModifierList();
final int startOffset = modifierList != null ? modifierList.getTextOffset() : clazz.getTextOffset();
final GrImplementsClause implementsClause = clazz.getImplementsClause();
final int endOffset;
if (implementsClause != null) {
endOffset = implementsClause.getTextRange().getEndOffset();
} else {
final GrExtendsClause extendsClause = clazz.getExtendsClause();
if (extendsClause != null) {
endOffset = extendsClause.getTextRange().getEndOffset();
} else {
endOffset = clazz.getNameIdentifierGroovy().getTextRange().getEndOffset();
}
}
return new TextRange(startOffset, endOffset);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause in project intellij-community by JetBrains.
the class GrPullUpHelper method addClassToSupers.
private void addClassToSupers(MemberInfo info, PsiClass aClass, PsiSubstitutor substitutor, GrTypeDefinition targetSuperClass) {
final PsiReferenceList sourceReferenceList = info.getSourceReferenceList();
LOG.assertTrue(sourceReferenceList != null);
PsiQualifiedReferenceElement ref = mySourceClass.equals(sourceReferenceList.getParent()) ? removeFromReferenceList(sourceReferenceList, aClass) : findReferenceToClass(sourceReferenceList, aClass);
if (ref != null && !targetSuperClass.isInheritor(aClass, false)) {
GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(myProject);
replaceMovedMemberTypeParameters(ref, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
GrReferenceList referenceList;
if (targetSuperClass.isInterface()) {
referenceList = targetSuperClass.getExtendsClause();
if (referenceList == null) {
GrExtendsClause newClause = GroovyPsiElementFactory.getInstance(myProject).createExtendsClause();
PsiElement anchor = targetSuperClass.getTypeParameterList() != null ? targetSuperClass.getTypeParameterList() : targetSuperClass.getNameIdentifierGroovy();
referenceList = (GrReferenceList) targetSuperClass.addAfter(newClause, anchor);
addSpacesAround(referenceList);
}
} else {
referenceList = targetSuperClass.getImplementsClause();
if (referenceList == null) {
GrImplementsClause newClause = GroovyPsiElementFactory.getInstance(myProject).createImplementsClause();
PsiElement anchor = targetSuperClass.getExtendsClause() != null ? targetSuperClass.getExtendsClause() : targetSuperClass.getTypeParameterList() != null ? targetSuperClass.getTypeParameterList() : targetSuperClass.getNameIdentifierGroovy();
referenceList = (GrReferenceList) targetSuperClass.addAfter(newClause, anchor);
addSpacesAround(referenceList);
}
}
assert referenceList != null;
referenceList.add(ref);
}
}
Aggregations