use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression in project intellij-community by JetBrains.
the class ConjunctionPredicate method satisfiedBy.
@Override
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof GrBinaryExpression)) {
return false;
}
final GrBinaryExpression expression = (GrBinaryExpression) element;
final IElementType tokenType = expression.getOperationTokenType();
if (tokenType == null)
return false;
if (!tokenType.equals(GroovyTokenTypes.mLAND) && !tokenType.equals(GroovyTokenTypes.mLOR)) {
return false;
}
return !ErrorUtil.containsError(element);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression in project intellij-community by JetBrains.
the class DemorgansLawIntention method isConjunctionExpression.
private static boolean isConjunctionExpression(PsiElement exp, IElementType conjunctionType) {
if (!(exp instanceof GrBinaryExpression))
return false;
final GrBinaryExpression binExp = (GrBinaryExpression) exp;
final IElementType tokenType = binExp.getOperationTokenType();
return conjunctionType.equals(tokenType);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression 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);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression 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");
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression 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);
}
Aggregations