Skip to content

Commit a30fd0d

Browse files
datho7561mickaelistria
authored andcommitted
Improve extends/implements completion
- precalculate extends or implements info - When there is no prefix, suggest types declared in the same class, eg. suggest `MyInterface` in the following snippet ```java public class MyClass implements | { } interface MyInterface {} ``` - Better recovery of bindings for classes with incomplete extends or implements sections - previously the binding key was always `*`, which caused many that relied on the binding key to break - Use ExtendsOrImplements info filtering in more places Signed-off-by: David Thompson <[email protected]>
1 parent 3dd1f9e commit a30fd0d

File tree

3 files changed

+210
-67
lines changed

3 files changed

+210
-67
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.eclipse.jdt.internal.codeassist.DOMCompletionUtil;
3131
import org.eclipse.jdt.internal.javac.dom.JavacAnnotationBinding;
3232
import org.eclipse.jdt.internal.javac.dom.JavacErrorMethodBinding;
33+
import org.eclipse.jdt.internal.javac.dom.JavacErrorTypeBinding;
3334
import org.eclipse.jdt.internal.javac.dom.JavacLambdaBinding;
3435
import org.eclipse.jdt.internal.javac.dom.JavacMemberValuePairBinding;
3536
import org.eclipse.jdt.internal.javac.dom.JavacMethodBinding;
@@ -69,6 +70,7 @@
6970
import com.sun.tools.javac.code.Type.ModuleType;
7071
import com.sun.tools.javac.code.Type.PackageType;
7172
import com.sun.tools.javac.code.Type.TypeVar;
73+
import com.sun.tools.javac.code.Type.UnknownType;
7274
import com.sun.tools.javac.code.TypeTag;
7375
import com.sun.tools.javac.code.Types;
7476
import com.sun.tools.javac.tree.JCTree;
@@ -709,6 +711,9 @@ ITypeBinding resolveType(RecordDeclaration type) {
709711
ITypeBinding resolveType(TypeDeclaration type) {
710712
resolve();
711713
JCTree javacNode = this.converter.domToJavac.get(type);
714+
if (javacNode instanceof JCClassDecl jcClassDecl && javacNode.type instanceof UnknownType && "<any?>".equals(javacNode.type.toString())) {
715+
return new JavacErrorTypeBinding(javacNode.type, javacNode.type.tsym, true, JavacBindingResolver.this, jcClassDecl.sym);
716+
}
712717
if (javacNode instanceof JCClassDecl jcClassDecl && jcClassDecl.type != null) {
713718
return this.bindings.getTypeBinding(jcClassDecl.type, true);
714719
}

0 commit comments

Comments
 (0)