correct level in highlighting:

highlight element X only when visiting X or its ascendant
This commit is contained in:
Alexey Kudravtsev
2014-02-10 20:03:58 +04:00
parent e0792ea2f7
commit ad661d92e4
33 changed files with 598 additions and 314 deletions
@@ -1,6 +1,6 @@
public class a {
<error descr="'f(int)' is already defined in 'a'">void f(int i)</error> { }
<error descr="'f(int)' is already defined in 'a'">void f(int i)</error> {
void f(int i) {
new c1() {
<error descr="'f1()' is already defined in 'Anonymous class derived from c1'">public void f1()</error> {}
@@ -28,6 +28,7 @@ public class a {
}
abstract class c1 {
abstract public void f1(int i);
Object o = new c1[0];
}
interface ii {
@@ -4,7 +4,7 @@ class m {
int r = 0;
new Runnable() {
public void run() {
int k = <error descr="Variable 'r' is accessed from within inner class. Needs to be declared final.">r</error>;
int k = <error descr="Variable 'r' is accessed from within inner class, needs to be declared final">r</error>;
int ii = i;
}
};
@@ -27,9 +27,9 @@ class UnsupportedFeatures {
<error descr="For-each loops are not supported at this language level">for (String s : args) { System.out.println(s); }</error>
List<error descr="Generics are not supported at this language level"><String></error> list =
new ArrayList<error descr="Diamond types are not supported at this language level"><></error>();
new ArrayList<error descr="Generics are not supported at this language level"><></error>();
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String s : list</error>) {}
<error descr="For-each loops are not supported at this language level">for (String s : list) {}</error>
Arrays.asList<error descr="'asList(java.lang.String...)' in 'java.util.Arrays' cannot be applied to '(java.lang.String)'">("")</error>;
<error descr="Incompatible types. Found: 'boolean', required: 'java.lang.Boolean'">Boolean b = true;</error>
<error descr="Incompatible types. Found: 'java.lang.Boolean', required: 'boolean'">boolean b1 = Boolean.TRUE;</error>
@@ -0,0 +1,49 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
@interface Anno { }
@Anno
class UnsupportedFeatures {
void m(String... args) throws Exception {
for (String s : args) { System.out.println(s); }
List<String> list =
new ArrayList<>();
for (String s : list) {}
Arrays.asList("");
Boolean b = true;
boolean b1 = Boolean.TRUE;
try { Reader r = new FileReader("/dev/null"); }
catch (<error descr="Multi-catches are not supported at this language level">FileNotFoundException | IOException e</error>) { e.printStackTrace(); }
try <error descr="Try-with-resources are not supported at this language level">(Reader r = new FileReader("/dev/null"))</error> { }
I i1 = <error descr="Method references are not supported at this language level">UnsupportedFeatures::m</error>;
I i2 = <error descr="Lambda expressions are not supported at this language level">() -> { }</error>;
}
interface I {
<error descr="Extension methods are not supported at this language level">default void m() { }</error>
}
}
@@ -24,6 +24,6 @@ class Usage {
m(Base1.F); //Base1.m(int)
m(F); //Base2.m(float), float Base2.F
F.class.getName(); // class Base2.F
m<error descr="Cannot resolve method 'm(?)'">(<error descr="Reference to 'IF' is ambiguous, both 'I1.IF' and 'I2.IF' match">IF</error>)</error>;
m(<error descr="Reference to 'IF' is ambiguous, both 'I1.IF' and 'I2.IF' match">IF</error>);
}
}
@@ -22,7 +22,10 @@ enum E {
}
interface I {
@<error descr="Duplicate annotation">Anno</error> public @<error descr="Duplicate annotation">Anno</error> Collection<<error descr="Type annotations are not supported at this language level">@Anno</error> String> method(@<error descr="Duplicate annotation">Anno</error> @<error descr="Duplicate annotation">Anno</error> Object o);
@<error descr="Duplicate annotation">Anno</error>
public @<error descr="Duplicate annotation">Anno</error>
Collection<<error descr="Type annotations are not supported at this language level">@Anno</error> String>
method(@<error descr="Duplicate annotation">Anno</error> @<error descr="Duplicate annotation">Anno</error> Object o);
}
@interface Caller {
@@ -22,8 +22,12 @@ class a {
for (Object oi: (Iterable)o) {}
for (<error descr="Incompatible types. Found: 'double', required: 'int'">int i:db</error>) {
// error descr="Incompatible types. Found: 'double', required: 'int'" was not shown because there is an error in nested for
for (int i : db) {
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'int'">int p: list</error>) {}
}
for (int gjkh : <error descr="foreach not applicable to type 'int'">222</error>) {
}
}
}
@@ -22,7 +22,7 @@ class a {
for (Object oi: (Iterable)o) {}
for (<error descr="Incompatible types. Found: 'double', required: 'int'">int i:db</error>) {
for (int i:db) {
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'int'">int p: list</error>) {}
}
}
@@ -1,6 +1,6 @@
public interface IDEA99969 {
default IntStream distinct(Stream s) {
return s.map<error descr="Ambiguous method call: both 'Stream.map(Function)' and 'Stream.map(IntFunction)' match">(i -> <error descr="Inconvertible types; cannot cast '<lambda parameter>' to 'int'">(int) i</error>)</error>;
return s.map(i -> <error descr="Inconvertible types; cannot cast '<lambda parameter>' to 'int'">(int) i</error>);
}
}
interface Stream<T> {
@@ -8,8 +8,8 @@ class Test {
IntStream mi = sp.map(Inner::foo);
Stream<Integer> mI = sp.map(Inner::fooBoxed);
IntStream li = sp.map<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner,?>)' and 'Stream.map(IntFunction<? super Inner>)' match">(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>())</error>;
Stream<Integer> lI = sp.map<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner,? extends Integer>)' and 'Stream.map(IntFunction<? super Inner>)' match">(inner -> inner.<error descr="Cannot resolve method 'fooBoxed()'">fooBoxed</error>())</error>;
IntStream li = sp.map(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>());
Stream<Integer> lI = sp.map(inner -> inner.<error descr="Cannot resolve method 'fooBoxed()'">fooBoxed</error>());
}
interface Stream<T> {
@@ -108,7 +108,7 @@ class ParameterIsEffectivelyFinal {
new Runnable() {
@Override
public void run() {
System.out.println(<error descr="Variable 'o' is accessed from within inner class. Needs to be declared final.">o</error>);
System.out.println(<error descr="Variable 'o' is accessed from within inner class, needs to be declared final">o</error>);
}
}.run();
return 0;
@@ -21,9 +21,9 @@ class Test {
}
void foo(Foo<String> as, final Foo<Character> ac) {
boolean b1 = as.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<String,Boolean>)' and 'Foo.forAll(II<String,String>)' match">(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> false)</error>)</error>;
String s1 = as.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<String,Boolean>)' and 'Foo.forAll(II<String,String>)' match">(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> "")</error>)</error>;
boolean b2 = as.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<String,Boolean>)' and 'Foo.forAll(II<String,String>)' match">(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> "")</error>)</error>;
boolean b1 = as.forAll(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> false)</error>);
String s1 = as.forAll(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> "")</error>);
boolean b2 = as.forAll(s -> ac.forAll<error descr="Ambiguous method call: both 'Foo.forAll(I<Character,Boolean>)' and 'Foo.forAll(II<Character,String>)' match">(c -> "")</error>);
String s2 = as.forAll2(s -> ac.forAll2(<error descr="Incompatible return type boolean in lambda expression">c -> false</error>));
boolean b3 = as.forAll((I<String, Boolean>)s -> ac.forAll((I<Character, Boolean>)<error descr="Incompatible return type String in lambda expression">c -> ""</error>));
String s3 = as.forAll((II<String, String>)s -> ac.forAll((II<Character, String>)<error descr="Incompatible return type boolean in lambda expression">c -> false</error>));
@@ -1,5 +1,5 @@
interface A {
default String <error descr="Default method toString overrides a member of java.lang.Object">toString</error>() {
default String <error descr="Default method 'toString' overrides a member of 'java.lang.Object'">toString</error>() {
return "";
}
}
@@ -23,10 +23,10 @@ class C {
interface II extends I {
default void m() {
I.super.m();
<error descr="Unqualified super reference is not allowed in extension method">super.m</error>();
<error descr="Unqualified super reference is not allowed in extension method">super.<error descr="Cannot resolve method 'm()'">m</error></error>();
System.out.println(I.super.i);
System.out.println<error descr="Cannot resolve method 'println(?)'">(<error descr="Unqualified super reference is not allowed in extension method">super.i</error>)</error>;
System.out.println(<error descr="Unqualified super reference is not allowed in extension method">super.<error descr="Cannot resolve symbol 'i'">i</error></error>);
}
void ma();
@@ -14,9 +14,9 @@ class Foo {
void foo(K k){}
void bar() {
foo<error descr="Ambiguous method call: both 'Foo.foo(I)' and 'Foo.foo(K)' match">((p) -> {
foo((p) -> {
System.out.println<error descr="Cannot resolve method 'println(<lambda parameter>)'">(p)</error>;
})</error>;
});
foo((p, k) -> {
System.out.println(p);
@@ -1,9 +0,0 @@
// "Implement Methods" "true"
class c {
void foo() {
new I<String>(<caret>
}
}
interface I<T> {
foo(T t);
}
@@ -1,4 +1,6 @@
// "Make 'victim' return 'boolean'" "true"
import java.util.*;
public class External {
void m1() {
if (new Out().victim(null)) {
@@ -1,4 +1,6 @@
// "Make 'victim' return 'boolean'" "true"
import java.util.*;
public class External {
void m1() {
if (new Out().<caret>victim(null)) {