Search in sources :

Example 1 with GrTypeParameter

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);
    }
}
Also used : GrTypeParameter(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter) ASTNode(com.intellij.lang.ASTNode)

Example 2 with GrTypeParameter

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;
}
Also used : GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) GrAnonymousClassDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition) GrTypeParameter(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with GrTypeParameter

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;
}
Also used : GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrClassInitializer(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer) GrTypeParameter(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) GrClosableBlock(org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock) GrVariableDeclarationImpl(org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrVariableDeclarationImpl) TextRange(com.intellij.openapi.util.TextRange)

Aggregations

GrTypeParameter (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter)3 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)2 ASTNode (com.intellij.lang.ASTNode)1 TextRange (com.intellij.openapi.util.TextRange)1 Nullable (org.jetbrains.annotations.Nullable)1 GrDocComment (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment)1 GrDocCommentOwner (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner)1 GrClassInitializer (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer)1 GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)1 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)1 GrClosableBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock)1 GrAnonymousClassDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition)1 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)1 GrVariableDeclarationImpl (org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrVariableDeclarationImpl)1