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;
}
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;
}
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);
}
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));
}
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;
}
Aggregations