Search in sources :

Example 16 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class DemorgansLawIntention method processIntention.

@Override
public void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
    GrBinaryExpression exp = (GrBinaryExpression) element;
    final IElementType tokenType = exp.getOperationTokenType();
    PsiElement parent = exp.getParent();
    while (isConjunctionExpression(parent, tokenType)) {
        exp = (GrBinaryExpression) parent;
        assert exp != null;
        parent = exp.getParent();
    }
    final String newExpression = convertConjunctionExpression(exp, tokenType);
    replaceExpressionWithNegatedExpressionString(newExpression, exp);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) GrBinaryExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression) PsiElement(com.intellij.psi.PsiElement)

Example 17 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class DemorgansLawIntention method getTextForElement.

@Override
protected String getTextForElement(PsiElement element) {
    final GrBinaryExpression binaryExpression = (GrBinaryExpression) element;
    final IElementType tokenType = binaryExpression.getOperationTokenType();
    if (GroovyTokenTypes.mLAND.equals(tokenType)) {
        return GroovyIntentionsBundle.message("demorgans.intention.name1");
    } else {
        return GroovyIntentionsBundle.message("demorgans.intention.name2");
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) GrBinaryExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression)

Example 18 with IElementType

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;
}
Also used : PsiDocComment(com.intellij.psi.javadoc.PsiDocComment) IElementType(com.intellij.psi.tree.IElementType) PsiComment(com.intellij.psi.PsiComment) PsiElement(com.intellij.psi.PsiElement)

Example 19 with IElementType

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);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiComment(com.intellij.psi.PsiComment)

Example 20 with IElementType

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);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) GrBinaryExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression)

Aggregations

IElementType (com.intellij.psi.tree.IElementType)843 ASTNode (com.intellij.lang.ASTNode)127 PsiBuilder (com.intellij.lang.PsiBuilder)121 Nullable (org.jetbrains.annotations.Nullable)100 NotNull (org.jetbrains.annotations.NotNull)78 PsiElement (com.intellij.psi.PsiElement)77 TextRange (com.intellij.openapi.util.TextRange)43 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)26 ArrayList (java.util.ArrayList)22 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)22 Lexer (com.intellij.lexer.Lexer)17 GrBinaryExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression)15 NonNls (org.jetbrains.annotations.NonNls)14 Document (com.intellij.openapi.editor.Document)13 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)13 LighterASTNode (com.intellij.lang.LighterASTNode)12 BracePair (com.intellij.lang.BracePair)10 Project (com.intellij.openapi.project.Project)9 PsiFile (com.intellij.psi.PsiFile)9 IncorrectOperationException (com.intellij.util.IncorrectOperationException)9