4949import org .eclipse .jdt .core .dom .IMethodBinding ;
5050import org .eclipse .jdt .core .dom .IModuleBinding ;
5151import org .eclipse .jdt .core .dom .IPackageBinding ;
52+ import org .eclipse .jdt .core .dom .ISignatureProvider ;
5253import org .eclipse .jdt .core .dom .ITypeBinding ;
5354import org .eclipse .jdt .core .dom .IVariableBinding ;
5455import org .eclipse .jdt .core .dom .JavacBindingResolver ;
56+ import org .eclipse .jdt .core .dom .JavacBindingResolver .BindingKeyException ;
5557import org .eclipse .jdt .core .dom .MethodDeclaration ;
5658import org .eclipse .jdt .core .dom .Modifier ;
5759import org .eclipse .jdt .core .dom .RecordDeclaration ;
5860import org .eclipse .jdt .core .dom .TypeDeclaration ;
59- import org .eclipse .jdt .core .dom .JavacBindingResolver .BindingKeyException ;
6061import org .eclipse .jdt .internal .compiler .codegen .ConstantPool ;
6162import org .eclipse .jdt .internal .core .BinaryType ;
6263import org .eclipse .jdt .internal .core .JavaElement ;
6768import com .sun .tools .javac .code .Attribute ;
6869import com .sun .tools .javac .code .Flags ;
6970import com .sun .tools .javac .code .Kinds ;
70- import com .sun .tools .javac .code .Symbol ;
71- import com .sun .tools .javac .code .Type ;
72- import com .sun .tools .javac .code .TypeTag ;
73- import com .sun .tools .javac .code .Types ;
7471import com .sun .tools .javac .code .Kinds .Kind ;
7572import com .sun .tools .javac .code .Kinds .KindSelector ;
73+ import com .sun .tools .javac .code .Symbol ;
7674import com .sun .tools .javac .code .Symbol .ClassSymbol ;
7775import com .sun .tools .javac .code .Symbol .CompletionFailure ;
7876import com .sun .tools .javac .code .Symbol .MethodSymbol ;
8179import com .sun .tools .javac .code .Symbol .TypeSymbol ;
8280import com .sun .tools .javac .code .Symbol .TypeVariableSymbol ;
8381import com .sun .tools .javac .code .Symbol .VarSymbol ;
82+ import com .sun .tools .javac .code .Type ;
8483import com .sun .tools .javac .code .Type .ArrayType ;
8584import com .sun .tools .javac .code .Type .ClassType ;
8685import com .sun .tools .javac .code .Type .ErrorType ;
9089import com .sun .tools .javac .code .Type .MethodType ;
9190import com .sun .tools .javac .code .Type .TypeVar ;
9291import com .sun .tools .javac .code .Type .WildcardType ;
92+ import com .sun .tools .javac .code .TypeTag ;
93+ import com .sun .tools .javac .code .Types ;
9394import com .sun .tools .javac .code .Types .FunctionDescriptorLookupError ;
9495import com .sun .tools .javac .util .Name ;
9596import com .sun .tools .javac .util .Names ;
9697
97- public abstract class JavacTypeBinding implements ITypeBinding {
98+ public abstract class JavacTypeBinding implements ITypeBinding , ISignatureProvider {
9899
99100 private static final ITypeBinding [] NO_TYPE_ARGUMENTS = new ITypeBinding [0 ];
100101
@@ -313,6 +314,10 @@ private static String removeTrailingSemicolon(String key) {
313314 return key .endsWith (";" ) ? key .substring (0 , key .length () - 1 ) : key ;
314315 }
315316
317+ public String getSignature () {
318+ return getKey (true , true );
319+ }
320+
316321 private String getKey (Type t ) {
317322 return getKey (t , this .typeSymbol .flatName ());
318323 }
@@ -321,13 +326,21 @@ public String getKey(boolean includeTypeParameters) {
321326 return getKey (this .type , this .typeSymbol .flatName (), includeTypeParameters );
322327 }
323328
329+ public String getKey (boolean includeTypeParameters , boolean ignoreFilenames ) {
330+ return getKey (this .type , this .typeSymbol .flatName (), includeTypeParameters , ignoreFilenames );
331+ }
332+
324333 public String getKey (Type t , Name n ) {
325334 return getKey (type , n , true );
326335 }
336+
327337 public String getKey (Type t , Name n , boolean includeTypeParameters ) {
338+ return getKey (t , n , includeTypeParameters , false );
339+ }
340+ public String getKey (Type t , Name n , boolean includeTypeParameters , boolean signatureMode ) {
328341 try {
329342 StringBuilder builder = new StringBuilder ();
330- getKey (builder , t , n , false , includeTypeParameters , this .resolver );
343+ getKey (builder , t , n , false , includeTypeParameters , signatureMode , this .resolver );
331344 return builder .toString ();
332345 } catch (BindingKeyException bke ) {
333346 return null ;
@@ -344,6 +357,10 @@ static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf, bool
344357 }
345358
346359 static void getKey (StringBuilder builder , Type typeToBuild , Name n , boolean isLeaf , boolean includeParameters , JavacBindingResolver resolver ) throws BindingKeyException {
360+ getKey (builder , typeToBuild , n , isLeaf , includeParameters , false , resolver );
361+ }
362+
363+ static void getKey (StringBuilder builder , Type typeToBuild , Name n , boolean isLeaf , boolean includeParameters , boolean signatureMode , JavacBindingResolver resolver ) throws BindingKeyException {
347364 if (typeToBuild instanceof Type .JCNoType ) {
348365 return ;
349366 }
@@ -390,7 +407,11 @@ static void getKey(StringBuilder builder, Type typeToBuild, Name n, boolean isLe
390407 * but the test suite expects test0502.A$182,
391408 * where 182 is the location in the source of the symbol.
392409 */
393- builder .append (n .toString ().replace ('.' , '/' ));
410+ if ( signatureMode ) {
411+ builder .append (n .toString ());
412+ } else {
413+ builder .append (n .toString ().replace ('.' , '/' ));
414+ }
394415 // This is a hack and will likely need to be enhanced
395416 if (typeToBuild .tsym instanceof ClassSymbol classSymbol && !(classSymbol .type instanceof ErrorType ) && classSymbol .owner instanceof PackageSymbol ) {
396417 JavaFileObject sourcefile = classSymbol .sourcefile ;
@@ -402,7 +423,7 @@ static void getKey(StringBuilder builder, Type typeToBuild, Name n, boolean isLe
402423 } catch (IllegalArgumentException e ) {
403424 // probably: uri is not a valid path
404425 }
405- if (fileName != null && !fileName .startsWith (classSymbol .getSimpleName ().toString ())) {
426+ if (fileName != null && !signatureMode && ! fileName .startsWith (classSymbol .getSimpleName ().toString ())) {
406427 // There are multiple top-level types in this file,
407428 // inject 'FileName~' before the type name to show that this type came from `FileName.java`
408429 // (eg. Lorg/eclipse/jdt/FileName~MyTopLevelType;)
0 commit comments