public ReplaceStaticVariableIncrementDecrement(PsiExpression reference, String originalClassName) { super(reference); this.originalClassName = originalClassName; final PsiPrefixExpression prefixExpr = PsiTreeUtil.getParentOfType(reference, PsiPrefixExpression.class); if (prefixExpr != null) { this.reference = prefixExpr; } else { this.reference = PsiTreeUtil.getParentOfType(reference, PsiPostfixExpression.class); } }
public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiPostfixExpression)) { return false; } final PsiPostfixExpression postfixExpression = (PsiPostfixExpression)element; final IElementType tokenType = postfixExpression.getOperationTokenType(); return !(!JavaTokenType.PLUSPLUS.equals(tokenType) && !JavaTokenType.MINUSMINUS.equals(tokenType)); }
@Override public String getTextForElement(PsiElement element) { final PsiJavaToken sign; if (element instanceof PsiPostfixExpression) { sign = ((PsiPostfixExpression)element).getOperationSign(); } else { sign = ((PsiPrefixExpression)element).getOperationSign(); } final String operator = sign.getText(); return IntentionPowerPackBundle.message( "extract.increment.intention.name", operator); }
@Override public void visitPostfixExpression(PsiPostfixExpression expression) { mVisitor.report("PsiPostfixExpression", expression.getText(), expression); super.visitExpression(expression); }