mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
respect precedence for div as production argument (IDEA-187205)
This commit is contained in:
+5
@@ -53,6 +53,11 @@ public class ReplaceExpressionUtil {
|
||||
if (priority < parentPriority) return true;
|
||||
PsiElement element = SourceTreeToPsiMap.treeElementToPsi(oldParent);
|
||||
IElementType opType = ((PsiPolyadicExpression)element).getOperationTokenType();
|
||||
IElementType newI = newExpr.getElementType();
|
||||
if (newI == JavaElementType.BINARY_EXPRESSION || newI == JavaElementType.POLYADIC_EXPRESSION) {
|
||||
IElementType newType = ((PsiPolyadicExpression)newExpr).getOperationTokenType();
|
||||
if (newType == JavaTokenType.DIV) return true;
|
||||
}
|
||||
return ((CompositeElement)oldParent).getChildRole(oldExpr) != ChildRole.LOPERAND &&
|
||||
opType != JavaTokenType.PLUS &&
|
||||
opType != JavaTokenType.ASTERISK &&
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant cast(s)" "true"
|
||||
class Test {
|
||||
{
|
||||
int i = 1;
|
||||
int j = 2;
|
||||
System.out.println(j * (i / j));
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant cast(s)" "true"
|
||||
class Test {
|
||||
{
|
||||
int i = 1;
|
||||
int j = 2;
|
||||
System.out.println(j * (i<caret>nt)(i / j));
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
|
||||
|
||||
public class RemoveRedundantCastTest extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
enableInspectionTool(new RedundantCastInspection());
|
||||
}
|
||||
|
||||
public void test() { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/redundantCast";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user