1111import java .util .ArrayList ;
1212import java .util .List ;
1313
14- import static com .sourcegraph .semanticdb_javac .Debugging .pprint ;
15-
1614public final class SemanticdbSignatures {
1715 private final GlobalSymbolsCache cache ;
1816 private final LocalSymbolsCache locals ;
1917
18+ private static final Semanticdb .Type UNRESOLVED_TYPE_REF =
19+ Semanticdb .Type .newBuilder ()
20+ .setTypeRef (TypeRef .newBuilder ().setSymbol ("unresolved_type#" ))
21+ .build ();
22+
2023 public SemanticdbSignatures (GlobalSymbolsCache cache , LocalSymbolsCache locals ) {
2124 this .cache = cache ;
2225 this .locals = locals ;
@@ -43,17 +46,14 @@ private Signature generateClassSignature(Symbol.ClassSymbol sym) {
4346 if (sym .getSuperclass () != Type .noType ) {
4447 Semanticdb .Type superType = generateType (sym .getSuperclass ());
4548 if (superType == null ) {
46- pprint ("CLASS GAVE NULL " + sym .getSuperclass () + " " + sym );
47- } else {
48- builder .addParents (superType );
49+ superType = UNRESOLVED_TYPE_REF ;
4950 }
51+ builder .addParents (superType );
5052 }
5153 for (Type iType : sym .getInterfaces ()) {
5254 Semanticdb .Type type = generateType (iType );
53- // this can happen if an interface type isnt properly resolved. Shows as _root_ in snapshots
5455 if (type == null ) {
55- pprint ("INTERFACE GAVE NULL " + iType + " " + sym );
56- continue ;
56+ type = UNRESOLVED_TYPE_REF ;
5757 }
5858 builder .addParents (type );
5959 }
@@ -85,8 +85,7 @@ private Signature generateMethodSignature(Symbol.MethodSymbol sym) {
8585 private Signature generateFieldSignature (Symbol .VarSymbol sym ) {
8686 Semanticdb .Type generateType = generateType (sym .type );
8787 if (generateType == null ) {
88- pprint ("FIELD TYPE GAVE NULL " + sym .type + " " + cache .semanticdbSymbol (sym , locals ));
89- return null ;
88+ generateType = UNRESOLVED_TYPE_REF ;
9089 }
9190 return Signature .newBuilder ()
9291 .setValueSignature (ValueSignature .newBuilder ().setTpe (generateType ))
@@ -100,7 +99,7 @@ private Signature generateTypeSignature(Symbol.TypeVariableSymbol sym) {
10099
101100 Semanticdb .Type upperBound = generateType (sym .type .getUpperBound ());
102101 if (upperBound != null ) builder .setUpperBound (upperBound );
103- if ( upperBound == null ) pprint ( "UPPER BOUND GAVE NULL " + sym + " " + sym . type . getUpperBound () );
102+ else builder . setUpperBound ( UNRESOLVED_TYPE_REF );
104103
105104 return Signature .newBuilder ().setTypeSignature (builder ).build ();
106105 }
@@ -138,8 +137,7 @@ public Semanticdb.Type visitDeclared(DeclaredType t, Void unused) {
138137 for (TypeMirror type : t .getTypeArguments ()) {
139138 Semanticdb .Type visited = super .visit (type );
140139 if (visited == null ) {
141- pprint ("NULL TYPE PARAM " + type + " " + type .getClass ());
142- continue ;
140+ visited = UNRESOLVED_TYPE_REF ;
143141 }
144142 typeParams .add (visited );
145143
@@ -191,8 +189,7 @@ public Semanticdb.Type visitDeclared(DeclaredType t, Void unused) {
191189 public Semanticdb .Type visitArray (ArrayType t , Void unused ) {
192190 Semanticdb .Type arrayComponentType = super .visit (t .getComponentType ());
193191 if (arrayComponentType == null ) {
194- pprint ("ARRAY GAVE NULL " + t .getComponentType () + " " + t );
195- return null ;
192+ arrayComponentType = UNRESOLVED_TYPE_REF ;
196193 }
197194 return Semanticdb .Type .newBuilder ()
198195 .setTypeRef (
0 commit comments