Skip to content

Commit

Permalink
Fixes CompletionContextTests.test0112
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <stryker@redhat.com>
  • Loading branch information
Rob Stryker committed Dec 9, 2024
1 parent 0615a26 commit b7d5e86
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.code.Attribute.Compound;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
Expand All @@ -60,6 +57,7 @@
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Symbol.TypeVariableSymbol;
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Type.ErrorType;
Expand All @@ -71,8 +69,9 @@
import com.sun.tools.javac.code.Type.ModuleType;
import com.sun.tools.javac.code.Type.PackageType;
import com.sun.tools.javac.code.Type.TypeVar;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.tree.JCTree.JCAnnotatedType;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
Expand All @@ -96,6 +95,7 @@
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.JCTree.JCWildcard;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.util.Context;

/**
Expand Down Expand Up @@ -1422,6 +1422,17 @@ public Types getTypes() {
return Types.instance(this.context);
}

@Override
ITypeBinding getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) {
char[] sig = referenceBinding.signature();
IBinding b = this.bindings.getBinding(new String(sig));
if( b instanceof ITypeBinding itb) {
return itb;
}
return null;
}


private java.util.List<TypeSymbol> getTypeArguments(final Name name) {
if (name.getParent() instanceof SimpleType simpleType) {
return getTypeArguments(simpleType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1208,25 +1208,28 @@ private void processMembers(ITypeBinding typeBinding, Bindings scope,
}

private static boolean findInSupers(ITypeBinding root, ITypeBinding toFind) {
String keyToFind = toFind.getErasure().getKey();
Queue<ITypeBinding> toCheck = new LinkedList<>();
Set<String> alreadyChecked = new HashSet<>();
toCheck.add(root.getErasure());
while (!toCheck.isEmpty()) {
ITypeBinding current = toCheck.poll();
String currentKey = current.getErasure().getKey();
if (alreadyChecked.contains(currentKey)) {
continue;
}
alreadyChecked.add(currentKey);
if (currentKey.equals(keyToFind)) {
return true;
}
for (ITypeBinding superInterface : current.getInterfaces()) {
toCheck.add(superInterface);
}
if (current.getSuperclass() != null) {
toCheck.add(current.getSuperclass());
ITypeBinding superFind = toFind.getErasure();
if( superFind != null ) {
String keyToFind = superFind.getKey();
Queue<ITypeBinding> toCheck = new LinkedList<>();
Set<String> alreadyChecked = new HashSet<>();
toCheck.add(root.getErasure());
while (!toCheck.isEmpty()) {
ITypeBinding current = toCheck.poll();
String currentKey = current.getErasure().getKey();
if (alreadyChecked.contains(currentKey)) {
continue;
}
alreadyChecked.add(currentKey);
if (currentKey.equals(keyToFind)) {
return true;
}
for (ITypeBinding superInterface : current.getInterfaces()) {
toCheck.add(superInterface);
}
if (current.getSuperclass() != null) {
toCheck.add(current.getSuperclass());
}
}
}
return false;
Expand Down

0 comments on commit b7d5e86

Please sign in to comment.