use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class GroovyStatementMover method nlsAfter.
private static boolean nlsAfter(@Nullable PsiElement element) {
if (element == null)
return false;
PsiElement sibling = element;
while (true) {
sibling = PsiTreeUtil.nextLeaf(sibling);
if (sibling == null) {
//eof
return true;
}
final String text = sibling.getText();
if (text.contains("\n")) {
return text.charAt(CharArrayUtil.shiftForward(text, 0, " \t")) == '\n';
}
if (!(sibling instanceof PsiComment) && !StringUtil.isEmptyOrSpaces(text) && !text.equals(";")) {
return false;
}
}
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class CStyleCommentPredicate 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();
if (!GroovyTokenTypes.mML_COMMENT.equals(type)) {
return false;
}
final PsiElement sibling = PsiTreeUtil.nextLeaf(comment);
if (sibling == null) {
return true;
}
if (!(isWhitespace(sibling))) {
return false;
}
final String whitespaceText = sibling.getText();
return whitespaceText.indexOf((int) '\n') >= 0 || whitespaceText.indexOf((int) '\r') >= 0;
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class ChangeToCStyleCommentIntention method isEndOfLineComment.
private boolean isEndOfLineComment(PsiElement element) {
if (!(element instanceof PsiComment)) {
return false;
}
final PsiComment comment = (PsiComment) element;
final IElementType tokenType = comment.getTokenType();
return GroovyTokenTypes.mSL_COMMENT.equals(tokenType);
}
use of com.intellij.psi.PsiComment in project intellij-community by JetBrains.
the class IdRefReference method getIdValue.
@Nullable
protected String getIdValue(final PsiElement element) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag) element;
String s = tag.getAttributeValue(IdReferenceProvider.ID_ATTR_NAME);
if (!myIdAttrsOnly) {
if (s == null)
s = tag.getAttributeValue(IdReferenceProvider.NAME_ATTR_NAME);
if (s == null)
s = tag.getAttributeValue(IdReferenceProvider.STYLE_ID_ATTR_NAME);
}
return s != null ? s : getImplicitIdRefValue(tag);
} else if (element instanceof PsiComment) {
return getImplicitIdValue((PsiComment) element);
}
return null;
}
use of com.intellij.psi.PsiComment in project kotlin by JetBrains.
the class KotlinDeclarationMover method getElementSourceLineRange.
@Override
protected LineRange getElementSourceLineRange(@NotNull PsiElement element, @NotNull Editor editor, @NotNull LineRange oldRange) {
PsiElement first;
PsiElement last;
if (element instanceof KtDeclaration) {
first = element.getFirstChild();
last = element.getLastChild();
if (first == null || last == null)
return null;
} else {
first = last = element;
}
TextRange textRange1 = first.getTextRange();
TextRange textRange2 = last.getTextRange();
Document doc = editor.getDocument();
if (doc.getTextLength() < textRange2.getEndOffset())
return null;
int startLine = editor.offsetToLogicalPosition(textRange1.getStartOffset()).line;
int endLine = editor.offsetToLogicalPosition(textRange2.getEndOffset()).line + 1;
if (element instanceof PsiComment || startLine == oldRange.startLine || startLine == oldRange.endLine || endLine == oldRange.startLine || endLine == oldRange.endLine) {
return new LineRange(startLine, endLine);
}
TextRange lineTextRange = new TextRange(doc.getLineStartOffset(oldRange.startLine), doc.getLineEndOffset(oldRange.endLine));
if (element instanceof KtDeclaration) {
for (PsiElement anchor : getDeclarationAnchors((KtDeclaration) element)) {
TextRange suspectTextRange = anchor.getTextRange();
if (suspectTextRange != null && lineTextRange.intersects(suspectTextRange))
return new LineRange(startLine, endLine);
}
}
return null;
}
Aggregations