[java-inspections] UseHashCodeMethodInspection: support double type

Also: fix comment processing
Improvement of IDEA-338114

GitOrigin-RevId: 87d057ccbea4262c40e2717c2ea3c004ac9865b0
This commit is contained in:
Tagir Valeev
2023-12-11 17:55:54 +01:00
committed by intellij-monorepo-bot
parent e356e99136
commit 6e1d684df0
14 changed files with 136 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ public class Test {
Long var = 1234567890123456789L;
public void testMethod() {
int result = var.hashCode();
/*shift amount*/
int result = var.hashCode();
}
}

View File

@@ -4,6 +4,7 @@ public class Test {
Long var1 = 1234567890123456784L;
public void testMethod(boolean f) {
int result = (f ? var : var1).hashCode();
/*shift amount*/
int result = (f ? var : var1).hashCode();
}
}

View File

@@ -0,0 +1,6 @@
// "Replace with 'Double.hashCode()'" "true-preview"
public class Test {
void test(double d) {
System.out.println(Double.hashCode(d));
}
}

View File

@@ -0,0 +1,7 @@
// "Replace with 'Double.hashCode()'" "true-preview"
public class Test {
void test(Double d) {
/*comment*/
System.out.println(d.hashCode());
}
}

View File

@@ -0,0 +1,8 @@
// "Replace with 'Long.hashCode()'" "true-preview"
public class Test {
void test(double d) {
long l = Double.doubleToLongBits(d);
System.out.println(Long.hashCode(l));
System.out.println(l);
}
}

View File

@@ -0,0 +1,8 @@
// "Replace with 'Long.hashCode()'" "true-preview"
public class Test {
void test(double d) {
long l = Double.doubleToLongBits(d);
d++;
System.out.println(Long.hashCode(l));
}
}

View File

@@ -3,6 +3,7 @@ public class Test {
long var = 1234567890123456789L;
public void testMethod() {
int result = Long.hashCode(var);
/*shift amount*/
int result = Long.hashCode(var);
}
}

View File

@@ -0,0 +1,7 @@
// "Replace with 'Double.hashCode()'" "true-preview"
public class Test {
void test(double d) {
long l = Double.doubleToLongBits(d);
System.out.println((int) (l<caret> ^ (l >>> 32)));
}
}

View File

@@ -0,0 +1,7 @@
// "Replace with 'Double.hashCode()'" "true-preview"
public class Test {
void test(Double d) {
long l = Double.doubleToLongBits(/*comment*/d);
System.out.println((int) (l ^ <caret>(l >>> 32)));
}
}

View File

@@ -0,0 +1,8 @@
// "Replace with 'Long.hashCode()'" "true-preview"
public class Test {
void test(double d) {
long l = Double.doubleToLongBits(d);
System.out.println((int) (l ^ (l<caret> >>> 32)));
System.out.println(l);
}
}

View File

@@ -0,0 +1,8 @@
// "Replace with 'Long.hashCode()'" "true-preview"
public class Test {
void test(double d) {
long l = Double.doubleToLongBits(d);
d++;
System.out.println((int) (l<caret> ^ (l >>> 32)));
}
}