[java-highlighting] Fix testdata, tooltips

Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: ed0cf0daf5dbfb034882d49ad5e9c03f264b451e
This commit is contained in:
Tagir Valeev
2025-01-21 14:40:02 +01:00
committed by intellij-monorepo-bot
parent a0a7e71dff
commit 059a080ab3
43 changed files with 95 additions and 99 deletions

View File

@@ -644,7 +644,6 @@ public final class JavaErrorKinds {
public static final Simple<PsiMethodCallExpression> CALL_EXPECTED = error("call.expected");
public static final Simple<PsiReferenceExpression> CALL_STATIC_INTERFACE_METHOD_QUALIFIER =
error(PsiReferenceExpression.class, "call.static.interface.method.qualifier")
.withAnchor(ref -> requireNonNullElse(ref.getReferenceNameElement(), ref))
.withRange(JavaErrorFormatUtil::getRange);
public static final Parameterized<PsiCall, PsiClass> CALL_FORMAL_VARARGS_ELEMENT_TYPE_INACCESSIBLE_HERE =
parameterized(PsiCall.class, PsiClass.class, "call.formal.varargs.element.type.inaccessible.here")

View File

@@ -142,7 +142,7 @@ public record JavaIncompatibleTypeErrorContext(@NotNull PsiType lType, @Nullable
else {
typeText = type.getCanonicalText();
}
return HtmlChunk.tag("span")
return HtmlChunk.span()
.setClass(matches ? JavaCompilationError.JAVA_DISPLAY_INFORMATION : JavaCompilationError.JAVA_DISPLAY_ERROR).addText(typeText);
}

View File

@@ -88,10 +88,12 @@ public record JavaMismatchedCallContext(@NotNull PsiExpressionList list,
PsiExpression[] expressions) {
HtmlBuilder table = new HtmlBuilder();
HtmlChunk.Element td = HtmlChunk.tag("td");
HtmlChunk requiredHeader = td.setClass(JavaCompilationError.JAVA_DISPLAY_GRAYED).style("padding-left: 16px; padding-right: 24px;")
.addText(JavaCompilationErrorBundle.message("call.type.mismatch.tooltip.required.type"));
HtmlChunk providedHeader = td.setClass(JavaCompilationError.JAVA_DISPLAY_GRAYED).style("padding-right: 28px;")
.addText(JavaCompilationErrorBundle.message("call.type.mismatch.tooltip.provided.type"));
HtmlChunk requiredHeader = td.style("padding-left: 16px; padding-right: 24px;").child(
HtmlChunk.span().setClass(JavaCompilationError.JAVA_DISPLAY_GRAYED)
.addText(JavaCompilationErrorBundle.message("call.type.mismatch.tooltip.required.type")));
HtmlChunk providedHeader = td.style("padding-right: 28px;").child(
HtmlChunk.span().setClass(JavaCompilationError.JAVA_DISPLAY_GRAYED)
.addText(JavaCompilationErrorBundle.message("call.type.mismatch.tooltip.provided.type")));
table.append(HtmlChunk.tag("tr").children(td, requiredHeader, providedHeader));
String parameterNameStyle = "padding:1px 4px 1px 4px;";
@@ -139,7 +141,7 @@ public record JavaMismatchedCallContext(@NotNull PsiExpressionList list,
@NotNull @NlsSafe String lTypeArguments,
@NotNull @NlsSafe String rRawType,
@NotNull @NlsSafe String rTypeArguments) {
return new HtmlBuilder().append(rRawType).append(rTypeArguments).toFragment();
return new HtmlBuilder().appendRaw(rRawType).appendRaw(rTypeArguments).toFragment();
}
@Override

View File

@@ -7,6 +7,6 @@ abstract class Test {
abstract <T> T test(Serializable type);
private void call(){
String s = <error descr="Incompatible types. Found: 'java.lang.String[]', required: 'java.lang.String'">test(String[].class);</error>
String s = <error descr="Incompatible types. Found: 'java.lang.String[]', required: 'java.lang.String'">test</error>(String[].class);
}
}

View File

@@ -3,6 +3,6 @@ import java.util.Map;
class C1<K,V> {
class C2<T> {C2(Comparator<? super T> pComparator) {}}
C1(Comparator<? super K> pComparator) {new C2<Map.Entry<K,V>>(<error descr="Incompatible types. Found: 'java.util.Comparator<java.util.Map.Entry<capture<? super K>,?>>', required: 'java.util.Comparator<? super java.util.Map.Entry<K,V>>'">m(pComparator)</error>);}
C1(Comparator<? super K> pComparator) {new C2<Map.Entry<K,V>>(<error descr="Incompatible types. Found: 'java.util.Comparator<java.util.Map.Entry<capture<? super K>,?>>', required: 'java.util.Comparator<? super java.util.Map.Entry<K,V>>'">m</error>(pComparator));}
static <T> Comparator<Map.Entry<T,?>> m(Comparator<T> pKeyComparator) {return null;}
}

View File

@@ -1,5 +1,5 @@
class Foo<T extends Enum> {
public T bar(Class<? extends T> type, String str) {
return <error descr="Incompatible types. Found: 'java.lang.Enum', required: 'T'">Enum.valueOf(type, str);</error>
return Enum.<error descr="Incompatible types. Found: 'java.lang.Enum', required: 'T'">valueOf</error>(type, str);
}
}

View File

@@ -11,6 +11,6 @@ abstract class A1{
abstract <T> T baz(List<? super T> a);
void bar(List<?> x){
String o = <error descr="Incompatible types. Found: 'capture<?>', required: 'java.lang.String'">baz(x);</error>
String o = <error descr="Incompatible types. Found: 'capture<?>', required: 'java.lang.String'">baz</error>(x);
}
}

View File

@@ -10,7 +10,7 @@ class Test {
public void test(Set<MyConsumer> set) {
@SuppressWarnings("unchecked")
Map<Parent, MyConsumer<Parent>> map = <error descr="Incompatible types. Found: 'java.util.Map<java.lang.Object,Test.MyConsumer>', required: 'java.util.Map<Test.Parent,Test.MyConsumer<Test.Parent>>'">create(set);</error>
Map<Parent, MyConsumer<Parent>> map = <error descr="Incompatible types. Found: 'java.util.Map<java.lang.Object,Test.MyConsumer>', required: 'java.util.Map<Test.Parent,Test.MyConsumer<Test.Parent>>'">create</error>(set);
}

View File

@@ -4,7 +4,7 @@ abstract class Group {
}
public <T extends Category> T get(Key<T> key) {
return <error descr="Incompatible types. Found: 'Category', required: 'T'">getCategory(key);</error>
return <error descr="Incompatible types. Found: 'Category', required: 'T'">getCategory</error>(key);
}
public abstract <R extends Category<R>> R getCategory(Key<R> key);

View File

@@ -10,7 +10,7 @@ class NachCollections<K,V> {
Collection<? super Map.Entry<K,V>> c2,
Consumer<Map.Entry<K, V>> a) {
c1.forEach(consumer(a));
c2.forEach(<error descr="Incompatible types. Found: 'java.util.function.Consumer<java.util.Map.Entry<K,V>>', required: 'java.util.function.Consumer<? super capture<? super java.util.Map.Entry<K,V>>>'">consumer(a)</error>);
c2.forEach(<error descr="Incompatible types. Found: 'java.util.function.Consumer<java.util.Map.Entry<K,V>>', required: 'java.util.function.Consumer<? super capture<? super java.util.Map.Entry<K,V>>>'">consumer</error>(a));
}
}

View File

@@ -7,8 +7,8 @@ public class Sample {
<B> B bar(G<B> gb) {return null;}
void f(G1 g1) {
G<String> l11 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'Sample.G<java.lang.String>'">bar(g1);</error>
String l1 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">bar(g1);</error>
G<String> l11 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'Sample.G<java.lang.String>'">bar</error>(g1);
String l1 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">bar</error>(g1);
Object o = bar(g1);
}
}

View File

@@ -2,14 +2,14 @@ class Test {
{
Holder h = null;
Result<String> r1 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">new Result<>(h);</error>
Result<String> r2 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">Result.create(h);</error>
Result<String> r2 = Result.<error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">create</error>(h);
Holder dataHolder = null;
Result<String> r3 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">new Result<>(new Holder<>(dataHolder));</error>
Result<String> r4 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">Result.create(new Holder<>(dataHolder));</error>
Result<String> r4 = Result.<error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">create</error>(new Holder<>(dataHolder));
Result<String> r5 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">new Result<>(Holder.create(dataHolder));</error>
Result<String> r6 = <error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">Result.create(Holder.create(dataHolder));</error>
Result<String> r6 = Result.<error descr="Incompatible types. Found: 'Result<Holder>', required: 'Result<java.lang.String>'">create</error>(Holder.create(dataHolder));
}
}

View File

@@ -3,10 +3,10 @@ import java.util.Map;
class Test {
public static void main(String[] args) {
Map<Object, Object> b = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.lang.Object>'">newMapTrie();</error>
Map<Object, Map<Object, Object>> c = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>'">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Object>>> d = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>'">newMapTrie();</error>
Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>>'">newMapTrie();</error>
Map<Object, Object> b = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.lang.Object>'">newMapTrie</error>();
Map<Object, Map<Object, Object>> c = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>'">newMapTrie</error>();
Map<Object, Map<Object, Map<Object, Object>>> d = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>'">newMapTrie</error>();
Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = <error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>>'">newMapTrie</error>();
}
public static <T extends Map<Byte, T>> T newMapTrie() {

View File

@@ -6,7 +6,7 @@ class Test {
Factory factory = new Factory();
final Class<? extends ClassB> bClass = null;
ClassB b = factory.create(bClass);
String str = <error descr="Incompatible types. Found: 'capture<? extends Test.ClassB>', required: 'java.lang.String'">factory.create(bClass);</error>
String str = factory.<error descr="Incompatible types. Found: 'capture<? extends Test.ClassB>', required: 'java.lang.String'">create</error>(bClass);
}
public static class Factory {

View File

@@ -1,7 +1,7 @@
class Test {
void test(int num) {
m<error descr="'m(java.lang.String, int)' in 'Test' cannot be applied to '(java.lang.Integer)'">(num == 1 ? null : new Integer(1))</error>;
m<error descr="Expected 2 arguments but found 1">(num == 1 ? null : new Integer(1))</error>;
}
void m(String s, int i) {}

View File

@@ -6,7 +6,7 @@ class Test {
}
void m(List l){
boolean foo = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'boolean'">foo(l);</error>
String s = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">foo(l);</error>
boolean foo = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'boolean'">foo</error>(l);
String s = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">foo</error>(l);
}
}

View File

@@ -5,9 +5,9 @@ import java.util.stream.Collectors;
// IDEA-362351
public class FriendlyMessageInBadInference {
void test(Map<Integer, Integer> someMap) {
use(<error descr="Incompatible types. Found: 'java.util.HashMap<java.lang.Integer,java.lang.Integer>', required: 'java.lang.Throwable'">someMap.entrySet().stream()
use(someMap.entrySet().stream()
.sorted(Comparator.comparingInt(Entry::getKey))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (k1, k2) -> k1, HashMap::new))</error>);
.<error descr="Incompatible types. Found: 'java.util.HashMap<java.lang.Integer,java.lang.Integer>', required: 'java.lang.Throwable'">collect</error>(Collectors.toMap(Entry::getKey, Entry::getValue, (k1, k2) -> k1, HashMap::new)));
}
void use(Throwable t) {}

View File

@@ -37,7 +37,7 @@ class Test1 {
if (s.equals("1")) {
return Option.option(1);
} else {
return <error descr="Incompatible types. Found: 'Test1.Option<java.lang.String>', required: 'Test1.Option<java.lang.Integer>'">Option.option("2");</error>
return Option.<error descr="Incompatible types. Found: 'Test1.Option<java.lang.String>', required: 'Test1.Option<java.lang.Integer>'">option</error>("2");
}
};
}

View File

@@ -12,7 +12,7 @@ class TypeArgsConsistency {
I<Integer> i1 = (i, j) -> i + j;
foo((i, j) -> i + j);
I<Integer> i2 = bar((i, j) -> i + j);
I<Integer> i3 = <error descr="Incompatible types. Found: 'TypeArgsConsistency.I<java.lang.String>', required: 'TypeArgsConsistency.I<java.lang.Integer>'">bar((i, j) -> "" + i + j);</error>
I<Integer> i3 = <error descr="Incompatible types. Found: 'TypeArgsConsistency.I<java.lang.String>', required: 'TypeArgsConsistency.I<java.lang.Integer>'">bar</error>((i, j) -> "" + i + j);
}
}
@@ -43,7 +43,7 @@ class TypeArgsConsistency2 {
I<Integer> i1 = bar(x -> x);
I1<Integer> i2 = bar1(x -> 1);
I2<String> aI2 = bar2(x -> "");
I2<Integer> aI28 = <error descr="Incompatible types. Found: 'TypeArgsConsistency2.I2<java.lang.String>', required: 'TypeArgsConsistency2.I2<java.lang.Integer>'">bar2( x-> "");</error>
I2<Integer> aI28 = <error descr="Incompatible types. Found: 'TypeArgsConsistency2.I2<java.lang.String>', required: 'TypeArgsConsistency2.I2<java.lang.Integer>'">bar2</error>( x-> "");
I2<Integer> i3 = bar2(x -> x);
I2<Integer> i4 = bar2(x -> foooI());
System.out.println(i4.foo(2));

View File

@@ -4,7 +4,7 @@ import static p.Boo.*;
class FooImpl implements Foo, Boo {
public void baz() {
<error descr="Static method may only be called on its containing interface">foo();</error>
<error descr="Static method may only be called on its containing interface">foo</error>();
bar();
boo();
}

View File

@@ -2,6 +2,6 @@ import static p.Foo.FooEx.<error descr="Static method may only be called on its
class FooImpl {
public void baz() {
<error descr="Static method may only be called on its containing interface">foo();</error>
<error descr="Static method may only be called on its containing interface">foo</error>();
}
}

View File

@@ -11,14 +11,14 @@ class Bug {
interface IFunction extends Function<Integer, Integer> {
static void a() {
Function<Integer, Integer> identity = <error descr="Static method may only be called on its containing interface">identity();</error>
Function<Integer, Integer> identity = <error descr="Static method may only be called on its containing interface">identity</error>();
}
}
public void foo() {
Function<Integer, Integer> f = Function.identity();
Function<Integer, Integer> g = <error descr="Static method may only be called on its containing interface">f.identity();</error>
Function<Integer, Integer> g = f.<error descr="Static method may only be called on its containing interface">identity</error>();
Function<Integer, Integer> h = IFunction.<error descr="Static method may only be called on its containing interface">identity</error>();
}
@@ -40,15 +40,15 @@ class StaticMethodInterfaceExample {
}
public <T extends MyImplementation> void doStuff1() {
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
T.<error descr="Static method may only be called on its containing interface">staticMethod</error>();
}
public <T extends MyInterface & X> void doStuff2() {
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
T.<error descr="Static method may only be called on its containing interface">staticMethod</error>();
}
public <T extends MyImplementation & MyInterface> void doStuff3() {
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
T.<error descr="Static method may only be called on its containing interface">staticMethod</error>();
}
}
}

View File

@@ -4,7 +4,7 @@ public class ExTest {
}
{
Block<String> b = <error descr="Unhandled exception: ExTest.Ex">ExTest::maybeThrow;</error>
Block<String> b = ExTest::<error descr="Unhandled exception: ExTest.Ex">maybeThrow</error>;
}

View File

@@ -6,7 +6,7 @@ import java.util.function.Function;
class Test {
{
final Map<Comparable, List<Collection<?>>> families = <error descr="Incompatible types. Found: 'java.util.Map<java.lang.Integer,java.util.List<java.lang.Object>>', required: 'java.util.Map<java.lang.Comparable,java.util.List<java.util.Collection<?>>>'">sortingMerge((s) -> 0);</error>
final Map<Comparable, List<Collection<?>>> families = <error descr="Incompatible types. Found: 'java.util.Map<java.lang.Integer,java.util.List<java.lang.Object>>', required: 'java.util.Map<java.lang.Comparable,java.util.List<java.util.Collection<?>>>'">sortingMerge</error>((s) -> 0);
}
private <C extends Comparable<C>, T> Map<C, List<T>> sortingMerge(Function<T, C> keyFunction) {

View File

@@ -33,6 +33,6 @@ class Test1 {
{
bar(l -> <error descr="Unhandled exception: Test1.MyEx">baz</error>(l));
bar(<error descr="Unhandled exception: Test1.MyEx">this::baz</error>);
bar(this::<error descr="Unhandled exception: Test1.MyEx">baz</error>);
}
}

View File

@@ -22,10 +22,10 @@ abstract class FooBar<M> {
}
class Test {
<T> List<List<Object>> foo(List<T> objects, Function<T, ?>... functions) {
return <error descr="Incompatible types. Found: 'java.util.List<java.util.List<capture<?>>>', required: 'java.util.List<java.util.List<java.lang.Object>>'">objects.stream()
return objects.stream()
.map(object -> Arrays.stream(functions)
.map(fn -> fn.apply(object))
.collect(toList()))
.collect(toList());</error>
.<error descr="Incompatible types. Found: 'java.util.List<java.util.List<capture<?>>>', required: 'java.util.List<java.util.List<java.lang.Object>>'">collect</error>(toList());
}
}

View File

@@ -9,7 +9,7 @@ class A {
<error descr="Missing return statement">}</error>);
Map<Integer, Integer> map = <error descr="Incompatible types. Found: 'java.util.stream.Stream<java.lang.Integer>', required: 'java.util.Map<java.lang.Integer,java.lang.Integer>'">Stream.iterate(5, t -> t + 5);</error>
Map<Integer, Integer> map = Stream.<error descr="Incompatible types. Found: 'java.util.stream.Stream<java.lang.Integer>', required: 'java.util.Map<java.lang.Integer,java.lang.Integer>'">iterate</error>(5, t -> t + 5);
}

View File

@@ -26,7 +26,7 @@ abstract class NoFormalParamTypeInferenceNeeded {
{
map(a -> zip(text -> text));
zip(a -> zip(text -> text));
Integer zip = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.Integer'">zip(a -> zip(text -> text));</error>
Integer zip = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.Integer'">zip</error>(a -> zip(text -> text));
}
}

View File

@@ -16,6 +16,6 @@ class Test {
}
public void failure() {
consume(<error descr="Unhandled exception: java.lang.Exception">this::produce</error>);
consume(this::<error descr="Unhandled exception: java.lang.Exception">produce</error>);
}
}

View File

@@ -8,6 +8,6 @@ class Either<E>{
}
class TestClass {
Map<Boolean, Either<String>> test(final Stream<Either<String>> eitherStream) {
return <error descr="Incompatible types. Found: 'java.util.Map<java.lang.Boolean,java.util.List<Either<java.lang.String>>>', required: 'java.util.Map<java.lang.Boolean,Either<java.lang.String>>'">eitherStream.collect(Collectors.groupingBy(Either::isRight));</error>
return eitherStream.<error descr="Incompatible types. Found: 'java.util.Map<java.lang.Boolean,java.util.List<Either<java.lang.String>>>', required: 'java.util.Map<java.lang.Boolean,Either<java.lang.String>>'">collect</error>(Collectors.groupingBy(Either::isRight));
}
}

View File

@@ -4,8 +4,8 @@ import java.util.stream.Collectors;
class MyTest {
static Map<String, Meeting> getMeetingsById(List<Meeting> meetings){
return <error descr="Incompatible types. Found: 'java.util.Map<java.lang.String,java.util.List<Meeting>>', required: 'java.util.Map<java.lang.String,Meeting>'">meetings.stream()
.collect(Collectors.groupingBy(Meeting::getId));</error>
return meetings.stream()
.<error descr="Incompatible types. Found: 'java.util.Map<java.lang.String,java.util.List<Meeting>>', required: 'java.util.Map<java.lang.String,Meeting>'">collect</error>(Collectors.groupingBy(Meeting::getId));
}
}

View File

@@ -12,6 +12,6 @@ class Test {
void d() throws E2 {
a(b()::c);
a(<error descr="Unhandled exception: E2">this::e</error>);
a(this::<error descr="Unhandled exception: E2">e</error>);
}
}

View File

@@ -12,7 +12,7 @@ import java.util.function.Function;
class Test {
{
valueOf(<error descr="Incompatible types. Found: 'java.lang.Integer', required: 'char[]'">processFirst(x -> x)</error>);
valueOf(<error descr="Incompatible types. Found: 'java.lang.Integer', required: 'char[]'">processFirst</error>(x -> x));
}
public static <V> V processFirst(Function<Integer,V> f){

View File

@@ -9,6 +9,6 @@ class MyTest {
}
{
new MyTest("", <error descr="Incompatible types. Found: 'java.util.List<java.lang.Object>', required: 'int'">Collections.emptyList()</error>);
new MyTest("", Collections.<error descr="Incompatible types. Found: 'java.util.List<java.lang.Object>', required: 'int'">emptyList</error>());
}
}

View File

@@ -6,7 +6,7 @@ import java.util.stream.Stream;
class Test {
void foo() {
log(<error descr="Incompatible types. Found: 'java.util.TreeSet<java.lang.String>', required: 'java.lang.String[]'">get(TreeSet<String>::new)</error>);
log(<error descr="Incompatible types. Found: 'java.util.TreeSet<java.lang.String>', required: 'java.lang.String[]'">get</error>(TreeSet<String>::new));
}
private void log(String params[]) {

View File

@@ -39,7 +39,7 @@ class Test2 {
public static void main(IJ s, J<String> j) {
s.f("");
<error descr="Static method may only be called on its containing interface">j.j("");</error>
j.<error descr="Static method may only be called on its containing interface">j</error>("");
}
}

View File

@@ -1,6 +1,6 @@
class Test {
Test() {
foo(<error descr="Unhandled exception: java.lang.Exception">this::fs</error>);
foo(this::<error descr="Unhandled exception: java.lang.Exception">fs</error>);
foo((s) -> <error descr="Unhandled exception: java.lang.Exception">fs</error>(s));
}

View File

@@ -4,8 +4,8 @@ import java.util.stream.Collectors;
class Test {
Map<String, String> testMethodRef(Map<String, Integer> list) {
return <caret>list.entrySet().stream()
return list.entrySet().stream()
.filter(e -> !e.getKey().isEmpty())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
.<caret>collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}

View File

@@ -4,8 +4,8 @@ import java.util.stream.Collectors;
class Test {
void testMethodRef(Map<String, Integer> list) {
Map<String, String> map = list.<caret>entrySet().stream()
Map<String, String> map = list.entrySet().stream()
.filter(e -> !e.getKey().isEmpty())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
.<caret>collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}

View File

@@ -17,13 +17,13 @@ class MyTest {
void m(int i) {
String s = foo(switch (i) {default -> "str";});
String s1 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">foo(switch (i) {case 1 -> new Object(); default -> "str";});</error>
String s1 = <error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">foo</error>(switch (i) {case 1 -> new Object(); default -> "str";});
String s2 = foo(() -> switch (i) {
default -> "str";
});
String s3 = foo(() -> switch (i) {default -> bar();});
String s4 = foo(() -> switch (i) {default -> { yield bar();}});
String s5 = <error descr="Incompatible types. Found: 'java.lang.Integer', required: 'java.lang.String'">foo(() -> switch (i) {default -> { yield 1;}});</error>
String s5 = <error descr="Incompatible types. Found: 'java.lang.Integer', required: 'java.lang.String'">foo</error>(() -> switch (i) {default -> { yield 1;}});
String s6 = switch (i) {
case 1 -> <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">2</error>;
default -> {

View File

@@ -1,5 +1,5 @@
class Test{
{
for(int i = 0; <error>i = 10</error>; i++) {}
for(int i = 0; <error>i = 10;</error> i++) {}
}
}

View File

@@ -6,8 +6,8 @@ class X {
.flatMap(p1 -> IntStream.of(1, 2, 3)
.flatMap(p2 -> IntStream.of(4, 5)
.flatMap(p3 -> IntStream.of(6, 7)
.flatMap(p4 -> <error descr="Incompatible types. Found: 'java.util.stream.Stream<java.lang.Object>', required: 'java.util.stream.IntStream'">Stream.of(b1, b2)
.flatMap(p5 -> Stream.of(b1, b2)
.map(p6 -> null))</error>))));
.flatMap(p4 -> Stream.of(b1, b2)
.<error descr="Incompatible types. Found: 'java.util.stream.Stream<java.lang.Object>', required: 'java.util.stream.IntStream'">flatMap</error>(p5 -> Stream.of(b1, b2)
.map(p6 -> null))))));
}
}

View File

@@ -1081,12 +1081,12 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
String red = ColorUtil.toHtmlColor(NamedColorUtil.getErrorForeground());
String expected = "<html><table>" +
"<tr>" +
"<td style='padding: 0px 16px 8px 4px;color: " + greyed+ "'>Required type:</td>" +
"<td style='padding: 0px 4px 8px 0px;'><font color=\"" + toolTipForeground + "\">String</font></td>" +
"<td style=\"padding: 0px 16px 8px 4px;\" style=\"color: " + greyed + "\">Required type:</td>" +
"<td style=\"padding: 0px 4px 8px 0px;\"><span style=\"color: " + toolTipForeground + "\">String</span></td>" +
"</tr>" +
"<tr>" +
"<td style='padding: 0px 16px 0px 4px;color: " + greyed + "'>Provided:</td>" +
"<td style='padding: 0px 4px 0px 0px;'><font color=\"" + red + "\">int</font></td>" +
"<td style=\"padding: 0px 16px 0px 4px;\" style=\"color: " + greyed + "\">Provided:</td>" +
"<td style=\"padding: 0px 4px 0px 0px;\"><span style=\"color: " + red + "\">int</span></td>" +
"</tr>" +
"</table></html>";
@@ -1104,14 +1104,13 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
String paramBgColor = ColorUtil.toHtmlColor(EditorColorsUtil.getGlobalOrDefaultColorScheme()
.getAttributes(DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT)
.getBackgroundColor());
int fontSize = StartupUiUtil.getLabelFont().getSize() - (SystemInfo.isWindows ? 0 : 1);
String expected = "<html><table>" +
"<tr><td/><td style=\"color: " + greyed + "; padding-left: 16px; padding-right: 24px;\">Required type</td>" +
"<td style=\"color: " + greyed + "; padding-right: 28px;\">Provided</td></tr>" +
"<tr><td><table><tr><td style=\"color: " + greyed + "; font-size:" + fontSize + "pt; padding:1px 4px 1px 4px;background-color: " + paramBgColor + ";\">list:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><font color=\"" + toolTipForeground + "\">String...</font></td>" +
"<td style=\"padding-right: 28px;\"><font color=\"" + red + "\">int</font></td></tr>" +
"<tr><td/><td style=\"padding-left: 16px; padding-right: 24px;\"/><td style=\"padding-right: 28px;\"><font color=\"" + red + "\">int</font></td></tr>" +
"<tr><td/><td style=\"padding-left: 16px; padding-right: 24px;\"><span style=\"color: " + greyed + "\">Required type</span></td>" +
"<td style=\"padding-right: 28px;\"><span style=\"color: " + greyed + "\">Provided</span></td></tr>" +
"<tr><td><table><tr><td style=\"color: " + greyed + "; background-color: " + paramBgColor + "\" style=\"padding:1px 4px 1px 4px;\">list:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><span style=\"color: " + toolTipForeground + "\">String...</span></td>" +
"<td style=\"padding-right: 28px;\"><span style=\"color: " + red + "\">int</span></td></tr>" +
"<tr><td/><td style=\"padding-left: 16px; padding-right: 24px;\"/><td style=\"padding-right: 28px;\"><span style=\"color: " + red + "\">int</span></td></tr>" +
"</table></html>";
doHighlighting()
@@ -1125,17 +1124,13 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
String toolTipForeground = ColorUtil.toHtmlColor(UIUtil.getToolTipForeground());
String greyed = ColorUtil.toHtmlColor(UIUtil.getContextHelpForeground());
String red = ColorUtil.toHtmlColor(NamedColorUtil.getErrorForeground());
String paramBgColor = ColorUtil.toHtmlColor(EditorColorsUtil.getGlobalOrDefaultColorScheme()
.getAttributes(DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT)
.getBackgroundColor());
int fontSize = StartupUiUtil.getLabelFont().getSize() - (SystemInfo.isWindows ? 0 : 1);
String expected = "<html><table>" +
"<tr>" +
"<td style='padding: 0px 16px 8px 4px;color: " + greyed + "'>Required type:</td>" +
"<td style='padding: 0px 4px 8px 0px;'><font color=\"" + toolTipForeground + "\">CharSequence</font></td>" +
"<td style=\"padding: 0px 16px 8px 4px;\" style=\"color: "+greyed+"\">Required type:</td>" +
"<td style=\"padding: 0px 4px 8px 0px;\"><span style=\"color: "+toolTipForeground+"\">CharSequence</span></td>" +
"</tr>" +
"<tr><td style='padding: 0px 16px 0px 4px;color: " + greyed + "'>Provided:</td>" +
"<td style='padding: 0px 4px 0px 0px;'><font color=\"" + red + "\">int</font></td></tr>" +
"<tr><td style=\"padding: 0px 16px 0px 4px;\" style=\"color: "+greyed+"\">Provided:</td>" +
"<td style=\"padding: 0px 4px 0px 0px;\"><span style=\"color: "+red+"\">int</span></td></tr>" +
"</table></html>";
doHighlighting()
@@ -1151,14 +1146,14 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
String red = ColorUtil.toHtmlColor(NamedColorUtil.getErrorForeground());
String expected = "<html><table>" +
"<tr>" +
"<td style='padding: 0px 16px 8px 4px;color: " + greyed + "'>Required type:</td>" +
"<td style='padding: 0px 4px 8px 0px;'><font color=\"" + toolTipForeground + "\">Class</font></td>" +
"<td style='padding: 0px 0px 8px 0px;'>&lt;<font color=\"" + toolTipForeground + "\">capture of ?</font>&gt;</td>" +
"<td style=\"padding: 0px 16px 8px 4px;\" style=\"color: "+greyed+"\">Required type:</td>" +
"<td style=\"padding: 0px 4px 8px 0px;\"><span style=\"color: "+toolTipForeground+"\">Class</span></td>" +
"<td style='padding: 0px 0px 8px 0px;'>&lt;<span style=\"color: "+toolTipForeground+"\">capture of ?</span>&gt;</td>" +
"</tr>" +
"<tr>" +
"<td style='padding: 0px 16px 0px 4px;color: " + greyed + "'>Provided:</td>" +
"<td style='padding: 0px 4px 0px 0px;'><font color=\"" + toolTipForeground + "\">Class</font></td>" +
"<td style='padding: 0px 0px 0px 0px;'>&lt;<font color=\"" + red + "\">capture of ?</font>&gt;</td></tr>" +
"<td style=\"padding: 0px 16px 0px 4px;\" style=\"color: "+greyed+"\">Provided:</td>" +
"<td style=\"padding: 0px 4px 0px 0px;\"><span style=\"color: "+toolTipForeground+"\">Class</span></td>" +
"<td style='padding: 0px 0px 0px 0px;'>&lt;<span style=\"color: "+red+"\">capture of ?</span>&gt;</td></tr>" +
"</table></html>";
doHighlighting()
@@ -1179,16 +1174,16 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
String expected = "<html><table>" +
"<tr>" +
"<td/>" +
"<td style=\"color: " + greyed + "; padding-left: 16px; padding-right: 24px;\">Required type</td>" +
"<td style=\"color: " + greyed + "; padding-right: 28px;\">Provided</td></tr>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><span style=\"color: " + greyed + "\">Required type</span></td>" +
"<td style=\"padding-right: 28px;\"><span style=\"color: " + greyed + "\">Provided</span></td></tr>" +
"<tr>" +
"<td><table><tr><td style=\"color: " + greyed + "; font-size:" + fontSize + "pt; padding:1px 4px 1px 4px;background-color: " + paramBgColor + ";\">integerList:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><font color=\"" + toolTipForeground + "\">List&lt;Integer&gt;</font></td>" +
"<td style=\"padding-right: 28px;\"><font color=\"" + toolTipForeground + "\">List</font>&lt;<font color=\"" + red + "\">String</font>&gt;</td></tr>" +
"<td><table><tr><td style=\"color: " + greyed + "; background-color: " + paramBgColor + "\" style=\"padding:1px 4px 1px 4px;\">integerList:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><span style=\"color: " + toolTipForeground + "\">List&lt;Integer&gt;</span></td>" +
"<td style=\"padding-right: 28px;\"><span style=\"color: " + toolTipForeground + "\">List</span>&lt;<span style=\"color: " + red + "\">String</span>&gt;</td></tr>" +
"<tr>" +
"<td><table><tr><td style=\"color: " + greyed + "; font-size:" + fontSize + "pt; padding:1px 4px 1px 4px;background-color: " + paramBgColor + ";\">stringList:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><font color=\"" + toolTipForeground+ "\">List&lt;String&gt;</font></td>" +
"<td style=\"padding-right: 28px;\"><font color=\"" + toolTipForeground + "\">List</font>&lt;<font color=\"" + red + "\">Integer</font>&gt;</td></tr>" +
"<td><table><tr><td style=\"color: " + greyed + "; background-color: " + paramBgColor + "\" style=\"padding:1px 4px 1px 4px;\">stringList:</td></tr></table></td>" +
"<td style=\"padding-left: 16px; padding-right: 24px;\"><span style=\"color: " + toolTipForeground + "\">List&lt;String&gt;</span></td>" +
"<td style=\"padding-right: 28px;\"><span style=\"color: " + toolTipForeground + "\">List</span>&lt;<span style=\"color: " + red + "\">Integer</span>&gt;</td></tr>" +
"</table></html>";
doHighlighting()