navigate to decompiled class if no source - #3411
Conversation
|
I think it was useful to have Absolute Path as it has more utility methods and also probably some validation. That might not be 100 percent needed in all places. |
tgodzik
left a comment
There was a problem hiding this comment.
Finally managed to take a look! I think it would be good to test it with some of the scalameta symbols that are generate from protobuf schema such as SymbolInformation
| .map(f => { | ||
| val uri = f.jar.toURI.toString() | ||
| val fullURI = | ||
| URI.create(s"jar:${uri}!/${symbol.stripSuffix("#")}.class") |
There was a problem hiding this comment.
This might not work for some more complex Scala symbols such as inner classes 馃
In that case we might want to use ClasspathSymbols and find the class that contains the symbol.
| .map(jarPath => List("--extraclasspath", jarPath.toString)) | ||
| .getOrElse(List.empty) | ||
| val args = extraClassPath ::: List( | ||
| "--analyseas", |
There was a problem hiding this comment.
No - although it does look it. The options is meant to mean ANALYSE_AS. Either jar or class
|
Thanks for this nice feature! Does it also works for scala js? |
|
@doofin I haven't used scala js. Can you give an example of what you mean? |
|
This is being done together with #3750, so closing |
Initial stab at scalameta/metals-feature-requests#210
I've no idea whether this is done in the correct area of code but it works so 馃し. If it is the correct area then I'll follow up with some tests.
One thing I've noticed is that
scala.meta.internal.mtags.SymbolDefinition(and a number of other classes used for passing file locations around) useAbsolutePathto refer to file locations. This is handy becausenio.Pathvalidates that the format is correct and there are lots of useful Path methods but it's not so handy when all that's really going on is URIs are being passed around.Downsides of using AbsolutePath are that any
jar:file///somejar.jar!/someclass.javastyle reference has to be opened in javaFileSystems#newFileSystem, even if you're not accessing it, or it throws an exception. Also - you can't use a virtual URI e.g.metalsDecode:jar:file:///somejar.jar!/someclass.class.cfrin AbsolutePath because it wrapsnio.Pathand I've not implemented ametalsDecodefilesystem as I think that's over the top.Is there a reason for using AbsolutePath rather than URI in all these places - or is it just historical?