use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause 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.GrImplementsClause 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.GrImplementsClause 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);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause in project intellij-community by JetBrains.
the class GrTypeDefinitionRangeHandler method getDeclarationRange.
@NotNull
@Override
public TextRange getDeclarationRange(@NotNull GrTypeDefinition aClass) {
if (aClass instanceof GrAnonymousClassDefinition) {
GrNewExpression call = (GrNewExpression) aClass.getParent();
int startOffset = call.getTextRange().getStartOffset();
int endOffset = call.getArgumentList().getTextRange().getEndOffset();
return new TextRange(startOffset, endOffset);
} else {
final PsiModifierList modifierList = aClass.getModifierList();
int startOffset = modifierList == null ? aClass.getTextRange().getStartOffset() : modifierList.getTextRange().getStartOffset();
final GrImplementsClause implementsList = aClass.getImplementsClause();
int endOffset = implementsList == null ? aClass.getTextRange().getEndOffset() : implementsList.getTextRange().getEndOffset();
return new TextRange(startOffset, endOffset);
}
}
Aggregations