use of com.intellij.psi.tree.IElementType 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.tree.IElementType 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.tree.IElementType in project intellij-community by JetBrains.
the class FlipConjunctionIntention method getTextForElement.
@Override
protected String getTextForElement(PsiElement element) {
final GrBinaryExpression binaryExpression = (GrBinaryExpression) element;
final IElementType tokenType = binaryExpression.getOperationTokenType();
final String conjunction = getConjunction(tokenType);
return GroovyIntentionsBundle.message("flip.smth.intention.name", conjunction);
}
use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.
the class XsltBreakpointHandler method getActualLineNumber.
public static int getActualLineNumber(Project project, @Nullable XSourcePosition position) {
if (position == null) {
return -1;
}
final PsiElement element = findContextElement(project, position);
if (element == null) {
return -1;
}
if (element instanceof XmlToken) {
final IElementType tokenType = ((XmlToken) element).getTokenType();
if (tokenType == XmlTokenType.XML_START_TAG_START || tokenType == XmlTokenType.XML_NAME) {
final PsiManager psiManager = PsiManager.getInstance(project);
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
final PsiFile psiFile = psiManager.findFile(position.getFile());
if (psiFile == null) {
return -1;
}
final Document document = documentManager.getDocument(psiFile);
if (document == null) {
return -1;
}
if (document.getLineNumber(element.getTextRange().getStartOffset()) == position.getLine()) {
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
if (tag != null) {
final ASTNode node = tag.getNode();
assert node != null;
// TODO: re-check if/when Xalan is supported
final ASTNode end = XmlChildRole.START_TAG_END_FINDER.findChild(node);
if (end != null) {
return document.getLineNumber(end.getTextRange().getEndOffset()) + 1;
} else {
final ASTNode end2 = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(node);
if (end2 != null) {
return document.getLineNumber(end2.getTextRange().getEndOffset()) + 1;
}
}
}
}
}
}
return -1;
}
use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.
the class YAMLParser method getShorthandIndentAddition.
private int getShorthandIndentAddition() {
final int offset = myBuilder.getCurrentOffset();
final IElementType nextToken = myBuilder.lookAhead(1);
if (nextToken != SEQUENCE_MARKER && nextToken != SCALAR_KEY) {
return 1;
}
if (myBuilder.rawLookup(1) == WHITESPACE) {
return myBuilder.rawTokenTypeStart(2) - offset;
} else {
return 1;
}
}
Aggregations