use of com.siyeh.ipp.base.PsiElementPredicate in project intellij-community by JetBrains.
the class PostfixPrefixIntention method getElementPredicate.
@NotNull
@Override
protected PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
@Override
public boolean satisfiedBy(PsiElement element) {
final IElementType tokenType;
if (element instanceof PsiPrefixExpression) {
final PsiPrefixExpression prefixExpression = (PsiPrefixExpression) element;
tokenType = prefixExpression.getOperationTokenType();
if (prefixExpression.getOperand() == null) {
return false;
}
} else if (element instanceof PsiPostfixExpression) {
final PsiPostfixExpression postfixExpression = (PsiPostfixExpression) element;
tokenType = postfixExpression.getOperationTokenType();
} else {
return false;
}
return JavaTokenType.PLUSPLUS.equals(tokenType) || JavaTokenType.MINUSMINUS.equals(tokenType);
}
};
}
use of com.siyeh.ipp.base.PsiElementPredicate in project intellij-community by JetBrains.
the class ConvertToNestedIfIntention method getElementPredicate.
@Override
@NotNull
public PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiReturnStatement)) {
return false;
}
final PsiReturnStatement returnStatement = (PsiReturnStatement) element;
final PsiExpression returnValue = ParenthesesUtils.stripParentheses(returnStatement.getReturnValue());
if (!(returnValue instanceof PsiPolyadicExpression)) {
return false;
}
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression) returnValue;
final IElementType tokenType = polyadicExpression.getOperationTokenType();
return tokenType == JavaTokenType.ANDAND || tokenType == JavaTokenType.OROR;
}
};
}
use of com.siyeh.ipp.base.PsiElementPredicate 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);
}
};
}
Aggregations