use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter in project intellij-community by JetBrains.
the class GrTypeParameterListImpl method addInternal.
@Override
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
appendParenthesesIfNeeded();
if (first == last && first.getPsi() instanceof GrTypeParameter) {
boolean hasParams = getTypeParameters().length > 0;
final ASTNode _anchor;
if (anchor == null) {
if (before.booleanValue()) {
_anchor = getLastChild().getNode();
} else {
_anchor = getFirstChild().getNode();
}
} else {
_anchor = anchor;
}
final ASTNode node = super.addInternal(first, last, _anchor, before);
if (hasParams) {
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", anchor != null ? anchor : node);
}
return node;
} else {
return super.addInternal(first, last, anchor, before);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter in project intellij-community by JetBrains.
the class SuppressForMemberFix method getContainer.
@Override
@Nullable
public GrDocCommentOwner getContainer(final PsiElement context) {
if (context == null || context instanceof PsiFile) {
return null;
}
GrDocCommentOwner container = null;
GrDocComment docComment = PsiTreeUtil.getParentOfType(context, GrDocComment.class);
if (docComment != null) {
container = docComment.getOwner();
}
if (container == null) {
container = PsiTreeUtil.getParentOfType(context, GrDocCommentOwner.class);
}
while (container instanceof GrAnonymousClassDefinition || container instanceof GrTypeParameter) {
container = PsiTreeUtil.getParentOfType(container, GrDocCommentOwner.class);
if (container == null)
return null;
}
if (myForClass) {
while (container != null) {
final GrTypeDefinition parentClass = PsiTreeUtil.getParentOfType(container, GrTypeDefinition.class);
if (parentClass == null && container instanceof GrTypeDefinition) {
return container;
}
container = parentClass;
}
}
return container;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter in project intellij-community by JetBrains.
the class GroovyLineMarkerProvider method getGroovyCategory.
private static int getGroovyCategory(@NotNull PsiElement element, @NotNull CharSequence documentChars) {
if (element instanceof GrVariableDeclarationImpl) {
GrVariable[] variables = ((GrVariableDeclarationImpl) element).getVariables();
if (variables.length == 1 && variables[0] instanceof GrField && variables[0].getInitializerGroovy() instanceof GrClosableBlock) {
return 2;
}
}
if (element instanceof GrField || element instanceof GrTypeParameter)
return 1;
if (element instanceof GrTypeDefinition || element instanceof GrClassInitializer)
return 2;
if (element instanceof GrMethod) {
if (((GrMethod) element).hasModifierProperty(PsiModifier.ABSTRACT) && !(((GrMethod) element).getBlock() != null && GrTraitUtil.isTrait(((GrMethod) element).getContainingClass()))) {
return 1;
}
TextRange textRange = element.getTextRange();
int start = textRange.getStartOffset();
int end = Math.min(documentChars.length(), textRange.getEndOffset());
int crlf = StringUtil.getLineBreakCount(documentChars.subSequence(start, end));
return crlf == 0 ? 1 : 2;
}
return 0;
}
Aggregations