Search in sources :

Example 11 with GrDocComment

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

the class GrDocCommentUtil method findDocComment.

@Nullable
public static GrDocComment findDocComment(GrDocCommentOwner owner) {
    if (owner.getFirstChild() instanceof GrDocComment) {
        return ((GrDocComment) owner.getFirstChild());
    }
    PsiElement element = owner instanceof GrVariable && owner.getParent() instanceof GrVariableDeclaration ? owner.getParent() : owner;
    element = skipWhiteSpacesAndStopOnDoc(element, false);
    if (element instanceof GrDocComment)
        return (GrDocComment) element;
    return null;
}
Also used : GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) GrVariableDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration) PsiElement(com.intellij.psi.PsiElement) GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with GrDocComment

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

the class GrDocInlinedTagImpl method setName.

@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
    final PsiElement nameElement = getNameElement();
    final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(getProject());
    final GrDocComment comment = factory.createDocCommentFromText("/** {@" + name + "}*/");
    nameElement.replace(comment.getTags()[0].getNameElement());
    return this;
}
Also used : GroovyPsiElementFactory(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory) PsiElement(com.intellij.psi.PsiElement) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment)

Example 13 with GrDocComment

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

the class GroovyPsiElementFactoryImpl method createDocReferenceElementFromFQN.

@NotNull
@Override
public GrDocReferenceElement createDocReferenceElementFromFQN(@NotNull String qName) {
    PsiFile file = createGroovyFileChecked("/** @see " + qName + " */");
    PsiElement element = file.getFirstChild();
    assert element instanceof GrDocComment;
    GrDocTag tag = PsiTreeUtil.getChildOfType(element, GrDocTag.class);
    assert tag != null : "Doc tag points to null";
    return PsiTreeUtil.getChildOfType(tag, GrDocReferenceElement.class);
}
Also used : GrDocTag(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag) GrDocComment(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with GrDocComment

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

Example 15 with GrDocComment

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

Aggregations

GrDocComment (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment)22 PsiElement (com.intellij.psi.PsiElement)9 GrDocCommentOwner (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner)8 NotNull (org.jetbrains.annotations.NotNull)5 Project (com.intellij.openapi.project.Project)4 Nullable (org.jetbrains.annotations.Nullable)4 GrDocTag (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag)4 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)4 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)3 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)3 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)3 GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)3 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)3 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)3 ASTNode (com.intellij.lang.ASTNode)2 Document (com.intellij.openapi.editor.Document)2 PsiComment (com.intellij.psi.PsiComment)2 PsiFile (com.intellij.psi.PsiFile)2 PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)2 LocalSearchScope (com.intellij.psi.search.LocalSearchScope)2