use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class ChainedCallChunk method splitMethodCallOnChunksByDots.
@NotNull
private static List<ChainedCallChunk> splitMethodCallOnChunksByDots(@NotNull List<ASTNode> nodes) {
List<ChainedCallChunk> result = new ArrayList<>();
List<ASTNode> current = new ArrayList<>();
for (ASTNode node : nodes) {
if (node.getElementType() == JavaTokenType.DOT || node.getPsi() instanceof PsiComment) {
if (!current.isEmpty()) {
result.add(new ChainedCallChunk(current));
}
current = new ArrayList<>();
}
current.add(node);
}
if (!current.isEmpty()) {
result.add(new ChainedCallChunk(current));
}
return result;
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class SuppressionUtil method createSuppression.
public static void createSuppression(@NotNull Project project, @NotNull PsiElement container, @NotNull String id, @NotNull Language commentLanguage) {
final String text = SUPPRESS_INSPECTIONS_TAG_NAME + " " + id;
PsiComment comment = createComment(project, text, commentLanguage);
container.getParent().addBefore(comment, container);
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class SuppressionUtil method getStatementToolSuppressedIn.
@Nullable
public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place, @NotNull String toolId, @NotNull Class<? extends PsiElement> statementClass, @NotNull Pattern suppressInLineCommentPattern) {
PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass);
if (statement != null) {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class);
if (prev instanceof PsiComment) {
String text = prev.getText();
Matcher matcher = suppressInLineCommentPattern.matcher(text);
if (matcher.matches() && isInspectionToolIdMentioned(matcher.group(1), toolId)) {
return prev;
}
}
}
return null;
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class LineCommentSelectioner method select.
@Override
public List<TextRange> select(PsiElement element, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = super.select(element, editorText, cursorOffset, editor);
PsiElement firstComment = element;
PsiElement e = element;
while (e.getPrevSibling() != null) {
if (e instanceof PsiComment) {
firstComment = e;
} else if (!(e instanceof PsiWhiteSpace)) {
break;
}
e = e.getPrevSibling();
}
PsiElement lastComment = element;
e = element;
while (e.getNextSibling() != null) {
if (e instanceof PsiComment) {
lastComment = e;
} else if (!(e instanceof PsiWhiteSpace)) {
break;
}
e = e.getNextSibling();
}
result.addAll(expandToWholeLine(editorText, new TextRange(firstComment.getTextRange().getStartOffset(), lastComment.getTextRange().getEndOffset())));
return result;
}
use of com.intellij.psi.PsiComment 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