Search in sources :

Example 51 with PsiDocComment

use of com.intellij.psi.javadoc.PsiDocComment in project intellij-community by JetBrains.

the class EndOfLineCommentPredicate method satisfiedBy.

@Override
public boolean satisfiedBy(PsiElement element) {
    if (!(element instanceof PsiComment)) {
        return false;
    }
    if (element instanceof PsiDocComment) {
        return false;
    }
    final PsiComment comment = (PsiComment) element;
    final IElementType type = comment.getTokenType();
    return GroovyTokenTypes.mSL_COMMENT.equals(type);
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment) IElementType(com.intellij.psi.tree.IElementType) PsiComment(com.intellij.psi.PsiComment)

Example 52 with PsiDocComment

use of com.intellij.psi.javadoc.PsiDocComment in project intellij-community by JetBrains.

the class GroovyMoveClassToInnerHandler method moveClass.

@Override
public PsiClass moveClass(@NotNull PsiClass aClass, @NotNull PsiClass targetClass) {
    if (!(aClass instanceof GrTypeDefinition))
        return null;
    GroovyChangeContextUtil.encodeContextInfo(aClass);
    PsiDocComment doc = aClass.getDocComment();
    PsiElement brace = targetClass.getRBrace();
    PsiClass newClass = (PsiClass) targetClass.addBefore(aClass, brace);
    PsiElement sibling = newClass.getPrevSibling();
    GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(targetClass.getProject());
    if (!org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isNewLine(sibling)) {
        targetClass.addBefore(factory.createLineTerminator("\n "), newClass);
    } else if (doc != null) {
        LOG.assertTrue(sibling != null);
        sibling.replace(factory.createLineTerminator(sibling.getText() + " "));
    }
    if (doc != null) {
        targetClass.addBefore(doc, newClass);
        targetClass.addBefore(factory.createLineTerminator("\n"), newClass);
    }
    if (targetClass.isInterface()) {
        PsiUtil.setModifierProperty(newClass, PsiModifier.PUBLIC, true);
    } else {
        PsiUtil.setModifierProperty(newClass, PsiModifier.STATIC, true);
    }
    GroovyChangeContextUtil.decodeContextInfo(newClass, null, null);
    return newClass;
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment) GroovyPsiElementFactory(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)

Example 53 with PsiDocComment

use of com.intellij.psi.javadoc.PsiDocComment in project intellij-community by JetBrains.

the class GenerationUtil method writeDocComment.

static void writeDocComment(StringBuilder buffer, PsiMember member, boolean addLineFeed) {
    if (member instanceof PsiDocCommentOwner) {
        final PsiDocComment comment = ((PsiDocCommentOwner) member).getDocComment();
        if (comment != null) {
            final String text = comment.getText();
            buffer.append(text);
            if (addLineFeed)
                buffer.append('\n');
        }
    }
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment)

Example 54 with PsiDocComment

use of com.intellij.psi.javadoc.PsiDocComment in project android by JetBrains.

the class InferSupportAnnotations method isHidden.

private static boolean isHidden(@NotNull PsiDocCommentOwner owner) {
    if (FILTER_HIDDEN) {
        while (owner != null) {
            PsiDocComment docComment = owner.getDocComment();
            if (docComment != null) {
                // We cna't just look for a PsiDocTag with name "hide" from docComment.getTags()
                // because that method only works for "@hide", not "{@hide}" which is used in a bunch
                // of places; we'd need to search for PsiInlineDocTags too
                String text = docComment.getText();
                return text.contains("@hide");
            }
            owner = PsiTreeUtil.getParentOfType(owner, PsiDocCommentOwner.class, true);
        }
    }
    return false;
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment)

Aggregations

PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)54 PsiDocTag (com.intellij.psi.javadoc.PsiDocTag)14 Project (com.intellij.openapi.project.Project)8 TextRange (com.intellij.openapi.util.TextRange)6 PsiElement (com.intellij.psi.PsiElement)6 IElementType (com.intellij.psi.tree.IElementType)6 NotNull (org.jetbrains.annotations.NotNull)5 ASTNode (com.intellij.lang.ASTNode)4 PsiComment (com.intellij.psi.PsiComment)4 CodeStyleManager (com.intellij.psi.codeStyle.CodeStyleManager)4 JavaCodeStyleManager (com.intellij.psi.codeStyle.JavaCodeStyleManager)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3 ArrayList (java.util.ArrayList)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiField (com.intellij.psi.PsiField)2 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)2 PsiDocParamRef (com.intellij.psi.impl.source.javadoc.PsiDocParamRef)2 HashMap (com.intellij.util.containers.HashMap)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2