Search in sources :

Example 11 with PsiPolyadicExpression

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

the class JavaPolyadicExpressionUnwrapper method doUnwrap.

@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
    final PsiPolyadicExpression parent = (PsiPolyadicExpression) element.getParent();
    final PsiExpression operand = findOperand(element, parent);
    if (operand == null) {
        return;
    }
    context.extractElement(operand, parent);
    context.delete(parent);
}
Also used : PsiExpression(com.intellij.psi.PsiExpression) PsiPolyadicExpression(com.intellij.psi.PsiPolyadicExpression)

Example 12 with PsiPolyadicExpression

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

the class JavaFormatterUtil method areSamePriorityBinaryExpressions.

/**
   * Allows to check if given {@code AST} nodes refer to binary expressions which have the same priority.
   *
   * @param node1 node to check
   * @param node2 node to check
   * @return {@code true} if given nodes are binary expressions and have the same priority;
   *         {@code false} otherwise
   */
public static boolean areSamePriorityBinaryExpressions(ASTNode node1, ASTNode node2) {
    if (node1 == null || node2 == null) {
        return false;
    }
    if (!(node1 instanceof PsiPolyadicExpression) || !(node2 instanceof PsiPolyadicExpression)) {
        return false;
    }
    PsiPolyadicExpression expression1 = (PsiPolyadicExpression) node1;
    PsiPolyadicExpression expression2 = (PsiPolyadicExpression) node2;
    return expression1.getOperationTokenType() == expression2.getOperationTokenType();
}
Also used : PsiPolyadicExpression(com.intellij.psi.PsiPolyadicExpression)

Example 13 with PsiPolyadicExpression

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

the class StringConcatenationInspection method buildFixes.

@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
    final InspectionGadgetsFix[] fixes = super.buildFixes(infos);
    final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression) infos[0];
    final SuppressForTestsScopeFix suppressFix = SuppressForTestsScopeFix.build(this, polyadicExpression);
    if (suppressFix == null) {
        return fixes;
    }
    final InspectionGadgetsFix[] newFixes = Arrays.copyOf(fixes, fixes.length + 1);
    newFixes[fixes.length] = suppressFix;
    return newFixes;
}
Also used : PsiPolyadicExpression(com.intellij.psi.PsiPolyadicExpression) InspectionGadgetsFix(com.siyeh.ig.InspectionGadgetsFix) SuppressForTestsScopeFix(com.siyeh.ig.fixes.SuppressForTestsScopeFix) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiPolyadicExpression (com.intellij.psi.PsiPolyadicExpression)13 PsiElement (com.intellij.psi.PsiElement)6 PsiExpression (com.intellij.psi.PsiExpression)6 PsiJavaToken (com.intellij.psi.PsiJavaToken)5 IElementType (com.intellij.psi.tree.IElementType)5 ASTNode (com.intellij.lang.ASTNode)2 Wrap (com.intellij.formatting.Wrap)1 PsiMethod (com.intellij.psi.PsiMethod)1 CompositeElement (com.intellij.psi.impl.source.tree.CompositeElement)1 InspectionGadgetsFix (com.siyeh.ig.InspectionGadgetsFix)1 SuppressForTestsScopeFix (com.siyeh.ig.fixes.SuppressForTestsScopeFix)1 NonNls (org.jetbrains.annotations.NonNls)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1