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