mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Improve the inspection "Multiple occurrences of the same expression" (IDEA-207247)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
void unmodifiableList(List<String> list) {
|
||||
List<String> u1 = <weak_warning descr="Multiple occurrences of 'Collections.unmodifiableList(list)'">Collections.unmodifiableList(list)</weak_warning>;
|
||||
List<String> u2 = <weak_warning descr="Multiple occurrences of 'Collections.unmodifiableList(list)'">Collections.unmodifiableList(list)</weak_warning>;
|
||||
}
|
||||
|
||||
void unmodifiableMap(Map<String, Integer> map) {
|
||||
Map<String, Integer> u1 = <weak_warning descr="Multiple occurrences of 'Collections.unmodifiableMap(map)'">Collections.unmodifiableMap(map)</weak_warning>;
|
||||
Map<String, Integer> u2 = <weak_warning descr="Multiple occurrences of 'Collections.unmodifiableMap(map)'">Collections.unmodifiableMap(map)</weak_warning>;
|
||||
}
|
||||
|
||||
void min(List<String> list) {
|
||||
String s1 = <weak_warning descr="Multiple occurrences of 'Collections.min(list)'">Collections.min(list)</weak_warning>;
|
||||
String s2 = <weak_warning descr="Multiple occurrences of 'Collections.min(list)'">Collections.min(list)</weak_warning>;
|
||||
}
|
||||
|
||||
void max(List<String> list) {
|
||||
String s1 = <weak_warning descr="Multiple occurrences of 'Collections.max(list)'">Collections.max(list)</weak_warning>;
|
||||
String s2 = <weak_warning descr="Multiple occurrences of 'Collections.max(list)'">Collections.max(list)</weak_warning>;
|
||||
}
|
||||
|
||||
void synchronizedList(List<String> list) {
|
||||
List<String> s1 = Collections.synchronizedList(list);
|
||||
List<String> s2 = Collections.synchronizedList(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
class A {
|
||||
static final int a = 0;
|
||||
|
||||
static class B {
|
||||
static final int b = 1;
|
||||
|
||||
static class C {
|
||||
static final int c = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void test1() {
|
||||
int i = A.a;
|
||||
int j = A.a;
|
||||
}
|
||||
|
||||
void test2() {
|
||||
int i = A.B.b;
|
||||
int j = A.B.b;
|
||||
}
|
||||
|
||||
void test3() {
|
||||
int i = A.B.C.c;
|
||||
int j = A.B.C.c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
int k;
|
||||
|
||||
void testThis() {
|
||||
int i = this.k;
|
||||
int j = this.k;
|
||||
}
|
||||
|
||||
static class B extends A {
|
||||
void testSuper() {
|
||||
int i = super.k;
|
||||
int j = super.k;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user