use of com.intellij.psi.PsiJavaToken in project intellij-community by JetBrains.
the class FlipExpressionIntention method getTextForElement.
@Override
public String getTextForElement(PsiElement element) {
final PsiPolyadicExpression expression = (PsiPolyadicExpression) element.getParent();
final PsiExpression[] operands = expression.getOperands();
final PsiJavaToken sign = expression.getTokenBeforeOperand(operands[1]);
final String operatorText = sign == null ? "" : sign.getText();
final IElementType tokenType = expression.getOperationTokenType();
final boolean commutative = ParenthesesUtils.isCommutativeOperator(tokenType);
if (commutative && !ExpressionUtils.isConcatenation(expression)) {
return IntentionPowerPackBundle.message("flip.smth.intention.name", operatorText);
} else {
return IntentionPowerPackBundle.message("flip.smth.intention.name1", operatorText);
}
}
use of com.intellij.psi.PsiJavaToken in project intellij-community by JetBrains.
the class ReplaceOperatorAssignmentWithAssignmentIntention method getTextForElement.
@Override
protected String getTextForElement(PsiElement element) {
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression) element;
final PsiJavaToken sign = assignmentExpression.getOperationSign();
final String operator = sign.getText();
return IntentionPowerPackBundle.message("replace.operator.assignment.with.assignment.intention.name", operator);
}
use of com.intellij.psi.PsiJavaToken in project intellij-community by JetBrains.
the class SimplifyIfElseIntention method getElementPredicate.
@NotNull
public PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken) element;
final PsiElement parent = token.getParent();
if (!(parent instanceof PsiIfStatement)) {
return false;
}
return TrivialIfInspection.isTrivial((PsiIfStatement) parent);
}
};
}
use of com.intellij.psi.PsiJavaToken in project intellij-community by JetBrains.
the class IfToSwitchPredicate method satisfiedBy.
@Override
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken) element;
if (token.getTokenType() != JavaTokenType.IF_KEYWORD) {
return false;
}
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiIfStatement)) {
return false;
}
final PsiIfStatement statement = (PsiIfStatement) parent;
if (ErrorUtil.containsError(statement)) {
return false;
}
return SwitchUtils.getSwitchExpression(statement, 0, false, true) != null;
}
Aggregations