Skip to content

Commit

Permalink
[WIP] cleanup code
Browse files Browse the repository at this point in the history
Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Apr 24, 2024
1 parent 01781a6 commit 21594e1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ ITypeBinding resolveType(EnumDeclaration enumDecl) {
return null;
}

/**
* TODO: we should avoid using this if possible
*/
public IBinding getBinding(final Symbol owner, final com.sun.tools.javac.code.Type type) {
if (owner instanceof final PackageSymbol other) {
return new JavacPackageBinding(other, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class JavacMemberValuePairBinding implements IMemberValuePairBinding {
private final JavacBindingResolver resolver;

public JavacMemberValuePairBinding(MethodSymbol key, Attribute value, JavacBindingResolver resolver) {
// FIXME
this.method = new JavacMethodBinding(key.type.asMethodType(), key, resolver);
this.value = value;
this.resolver = resolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void getKey(StringBuilder builder, MethodSymbol methodSymbol, JavacBindin
ownerSymbol = ownerSymbol.owner;
}
if (ownerSymbol instanceof TypeSymbol ownerTypeSymbol) {
JavacTypeBinding.getKey(builder, ownerTypeSymbol.type, false, true);
JavacTypeBinding.getKey(builder, resolver.getTypes().erasure(ownerTypeSymbol.type), false);
} else {
throw new IllegalArgumentException("Method has no owning class");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.javac.dom;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.lang.model.type.NullType;
Expand Down Expand Up @@ -40,7 +38,6 @@
import com.sun.tools.javac.code.Symbol.TypeVariableSymbol;
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Type;
import javax.lang.model.type.TypeKind;
import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Type.TypeVar;
Expand Down Expand Up @@ -120,7 +117,7 @@ public String getKey(Type t) {
return builder.toString();
}

static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf, boolean erased) {
static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
if (typeToBuild instanceof Type.JCNoType) {
return;
}
Expand Down Expand Up @@ -150,7 +147,7 @@ static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf, bool
}
}
builder.append(typeToBuild.asElement().getQualifiedName().toString().replace('.', '/'));
if (typeToBuild.isParameterized() && !erased) {
if (typeToBuild.isParameterized()) {
builder.append('<');
for (var typeArgument : typeToBuild.getTypeArguments()) {
getKey(builder, typeArgument, false);
Expand Down Expand Up @@ -182,10 +179,6 @@ static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf, bool
throw new UnsupportedOperationException("Unimplemented method 'getKey'");
}

static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
getKey(builder, typeToBuild, isLeaf, false);
}

@Override
public boolean isEqualTo(final IBinding binding) {
return binding instanceof final JavacTypeBinding other && //
Expand Down Expand Up @@ -348,10 +341,9 @@ public IMethodBinding getFunctionalInterfaceMethod() {

@Override
public ITypeBinding[] getInterfaces() {
if (this.typeSymbol instanceof final TypeVariableSymbol typeVarSymb && this.type instanceof TypeVar tv) {
List<Type> bounds = typeVarSymb.getBounds();
if (this.typeSymbol instanceof TypeVariableSymbol && this.type instanceof TypeVar tv) {
Type t = tv.getUpperBound();
if( t.tsym instanceof ClassSymbol cs) {
if (t.tsym instanceof ClassSymbol) {
JavacTypeBinding jtb = new JavacTypeBinding(t, this.resolver);
if( jtb.isInterface()) {
return new ITypeBinding[] {jtb};
Expand Down

0 comments on commit 21594e1

Please sign in to comment.