[java] Make Replace multiply with shift intention round towards -inf

#IDEA-384124 Fixed


(cherry picked from commit bc3e3ddc66db0c7b06f8ad5d281fe594a1c092db)

IJ-MR-189843

GitOrigin-RevId: 04f72906c4b22476b1c45644b097abeacd556c93
This commit is contained in:
Bart van Helvert
2026-02-12 15:57:26 +00:00
committed by intellij-monorepo-bot
parent dc0557eb61
commit 4608011210
6 changed files with 80 additions and 36 deletions
@@ -1,5 +1,5 @@
class Test {
void test(int foo) {
int x = foo >> 1<caret>2;
int x = foo >> 1<caret>2;
}
}
}
@@ -0,0 +1,5 @@
class Test {
void test(int foo) {
foo >>= 1<caret>2;
}
}
@@ -0,0 +1,5 @@
class Test {
void test(int foo) {
foo = Mat<caret>h.floorDiv(foo, 4096);
}
}
@@ -1,5 +1,5 @@
class Test {
void test(int foo) {
int x = foo / 40<caret>96;
int x = Math.flo<caret>orDiv(foo, 4096);
}
}
}
@@ -1,6 +1,8 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.siyeh.ipp.shift;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ipp.IPPTestCase;
public class ReplaceShiftWithMultiplyIntentionTest extends IPPTestCase {
@@ -11,7 +13,18 @@ public class ReplaceShiftWithMultiplyIntentionTest extends IPPTestCase {
public void testLeftShiftAssign() { doTest("Replace '<<=' with '*='"); }
public void testLongShiftAssign() { doTest("Replace '<<=' with '*='"); }
public void testParentheses() { doTest("Replace '<<' with '*'"); }
public void testRightShift() { doTest("Replace '>>' with '/'"); }
public void testRightShift() {
doTest("Replace '>>' with 'Math.floorDiv'");
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_7, () -> {
assertIntentionNotAvailable("Replace '>>' with 'Math.floorDiv'");
});
}
public void testRightShiftAssign() {
doTest("Replace '>>=' with 'Math.floorDiv'");
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_7, () -> {
assertIntentionNotAvailable("Replace '>>' with 'Math.floorDiv'");
});
}
@Override
protected String getRelativePath() {