Search in sources :

Example 6 with GrDocCommentOwner

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner 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 7 with GrDocCommentOwner

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner in project intellij-community by JetBrains.

the class SuppressForMemberFix method isAvailable.

@Override
public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
    final GrDocCommentOwner container = getContainer(context);
    myKey = container instanceof PsiClass ? "suppress.inspection.class" : container instanceof PsiMethod ? "suppress.inspection.method" : "suppress.inspection.field";
    return container != null && context.getManager().isInProject(context);
}
Also used : GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner)

Example 8 with GrDocCommentOwner

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner in project intellij-community by JetBrains.

the class GrParameterImpl method getUseScope.

@Override
@NotNull
public SearchScope getUseScope() {
    if (!isPhysical()) {
        final PsiFile file = getContainingFile();
        final PsiElement context = file.getContext();
        if (context != null)
            return new LocalSearchScope(context);
        return super.getUseScope();
    }
    final PsiElement scope = getDeclarationScope();
    if (scope instanceof GrDocCommentOwner) {
        GrDocCommentOwner owner = (GrDocCommentOwner) scope;
        final GrDocComment comment = owner.getDocComment();
        if (comment != null) {
            return new LocalSearchScope(new PsiElement[] { scope, comment });
        }
    }
    return new LocalSearchScope(scope);
}
Also used : LocalSearchScope(com.intellij.psi.search.LocalSearchScope) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with GrDocCommentOwner

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner in project intellij-community by JetBrains.

the class GrDocCommentUtil method findDocOwner.

@Nullable
public static GrDocCommentOwner findDocOwner(GroovyDocPsiElement docElement) {
    PsiElement element = docElement;
    while (element != null && element.getParent() instanceof GroovyDocPsiElement) element = element.getParent();
    if (element == null)
        return null;
    element = skipWhiteSpacesAndStopOnDoc(element, true);
    if (element instanceof GrDocCommentOwner)
        return (GrDocCommentOwner) element;
    if (element instanceof GrMembersDeclaration) {
        GrMember[] members = ((GrMembersDeclaration) element).getMembers();
        if (members.length > 0 && members[0] instanceof GrDocCommentOwner) {
            return (GrDocCommentOwner) members[0];
        }
    }
    return null;
}
Also used : GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) GrMember(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember) GrMembersDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) PsiElement(com.intellij.psi.PsiElement) GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with GrDocCommentOwner

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner in project intellij-community by JetBrains.

the class GroovyStatementMover method getElementToMove.

@Nullable
private static GroovyPsiElement getElementToMove(GroovyFileBase file, int offset) {
    offset = CharArrayUtil.shiftForward(file.getText(), offset, " \t");
    PsiElement element = file.findElementAt(offset);
    final GrDocComment docComment = PsiTreeUtil.getParentOfType(element, GrDocComment.class);
    if (docComment != null) {
        final GrDocCommentOwner owner = docComment.getOwner();
        if (owner != null) {
            element = owner;
        }
    }
    if (element instanceof PsiComment) {
        element = PsiTreeUtil.nextVisibleLeaf(element);
    }
    return (GroovyPsiElement) PsiTreeUtil.findFirstParent(element, element11 -> isMoveable(element11));
}
Also used : GrMembersDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration) Document(com.intellij.openapi.editor.Document) GrCaseLabel(org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseLabel) GrTypeDefinitionBody(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody) GrLiteral(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral) GrCodeBlock(org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock) GroovyFileBase(org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase) ArrayList(java.util.ArrayList) PsiRecursiveElementVisitor(com.intellij.psi.PsiRecursiveElementVisitor) PsiTreeUtil(com.intellij.psi.util.PsiTreeUtil) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) GrStatement(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement) GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) GroovyPsiElement(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) StringUtil(com.intellij.openapi.util.text.StringUtil) LineRange(com.intellij.codeInsight.editorActions.moveUpDown.LineRange) GrVariableDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) GrCaseSection(org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection) Editor(com.intellij.openapi.editor.Editor) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) StatementUpDownMover(com.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover) PsiComment(com.intellij.psi.PsiComment) HandlerUtils(org.jetbrains.plugins.groovy.editor.HandlerUtils) GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) NotNull(org.jetbrains.annotations.NotNull) CharArrayUtil(com.intellij.util.text.CharArrayUtil) PsiUtil(org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil) PsiComment(com.intellij.psi.PsiComment) GroovyPsiElement(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) PsiElement(com.intellij.psi.PsiElement) GroovyPsiElement(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GrDocCommentOwner (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner)10 GrDocComment (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment)8 Nullable (org.jetbrains.annotations.Nullable)4 Project (com.intellij.openapi.project.Project)3 PsiElement (com.intellij.psi.PsiElement)3 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)3 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)3 Document (com.intellij.openapi.editor.Document)2 PsiComment (com.intellij.psi.PsiComment)2 NotNull (org.jetbrains.annotations.NotNull)2 GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)2 GrMember (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember)2 GrMembersDeclaration (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration)2 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)1 MarkerType (com.intellij.codeInsight.daemon.impl.MarkerType)1 LineRange (com.intellij.codeInsight.editorActions.moveUpDown.LineRange)1 StatementUpDownMover (com.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover)1 CodeDocumentationAwareCommenter (com.intellij.lang.CodeDocumentationAwareCommenter)1 FileASTNode (com.intellij.lang.FileASTNode)1 AccessToken (com.intellij.openapi.application.AccessToken)1