eclipse-jdt/eclipse.jdt.core

[content assist] Ordering in the completion list is not as expected

Open

#347 aperta il 26 ago 2022

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Java (183 fork)auto 404
help wanted

Metriche repository

Star
 (233 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

@SuppressWarnings("preview")public class X { public static void print(Object p) { if (p instanceof Pair(Student(Object n1, int i), Teacher(Object n)) p1) { System.out.println(n); // Remove n and try to get proposals println is listed in top list } } public static void main(String[] args) { print(new Pair( new Student("abc", 15), new Teacher("123"))); print(new Pair( new Teacher("123"), new Student("abc", 1))); } } sealed interface Person permits Student, Teacher { String name(); } record Student(String name, int id) implements Person {} record Teacher(String name) implements Person {} record Pair(Person s, Person s1) {}

Remove n and try to get proposals for , println is listed in top list Where as in similar case gives expected order: public static void printLowerRight(Rectangle r) { int res = switch(r) { case Rectangle(ColoredPoint(Point(int x, int y), Color c), ColoredPoint lr) r1 when x > 1 -> { System.out.println("one" + ); // try to get proposals yield x; } case Rectangle(ColoredPoint(Point(int x, int y), Color c), ColoredPoint lr) r1 when x <= 0 -> { System.out.println("two"); yield x;
} default -> 0; };
System.out.println("Returns: " + res); }

Guida contributor