Turn Dotty import suggestions into code actions - #2536
Conversation
32c7576 to
560081c
Compare
| diagnostic.getRange.getEnd() | ||
| ) | ||
| compilers | ||
| .autoImports(textDocumentPositionParams, name, token) |
There was a problem hiding this comment.
autoImports aren't yet implemented for Scala 3, so we would have to make do without it.
There was a problem hiding this comment.
ah, I was just thinking about that. The only difficult thing would be to determine import position
| } | ||
| } | ||
|
|
||
| object SymbolNotFoundWithImportSuggestions { |
There was a problem hiding this comment.
I also wonder if we could get this from the compiler itself and maybe use completions?
| private val regexes = for { | ||
| fix <- List("One of the following imports", "The following import") | ||
| help <- List("fix ", "make progress towards fixing") | ||
| } yield s"""(?s)$fix imports might $help the problem:(.*)""".r |
There was a problem hiding this comment.
| } yield s"""(?s)$fix imports might $help the problem:(.*)""".r | |
| } yield s"""(?s)$fix might $help the problem:(.*)""".r |
?
| fix <- List("One of the following imports", "The following import") | ||
| help <- List("fix ", "make progress towards fixing") | ||
| } yield s"""(?s)$fix imports might $help the problem:(.*)""".r |
There was a problem hiding this comment.
The exact format of the compiler message strings is not stable and may change at any time, please do not rely on it. Instead, I encoruage you to contribute upstream a way to expose this information semantically in our Reporting API (we also implement scalafix-like rewrites which could be displayed as quick fix actions in vscode).
There was a problem hiding this comment.
Revisiting long after the fact. @smarter has any thought gone into what this would look like, exposing this information semantically? I've been thinking about this often lately and sort of year for an error index like rust has and more structured errors that we can use for stuff like this. I see some convos that touch on this a bit like this old convo, but has there been any design though or conversation around what this could look like in Dotty?
There was a problem hiding this comment.
has there been any design though or conversation around what this could look like in Dotty?
No, this is still waiting for a motivated individual to step up :).
|
Closing this for a few reasons:
Thanks everyone for the feedback |
|
Should we turn it into a feature request though? We might be able to get that data from the compiler anyway, so it might still be doable, but will need a greater amount of time. |
A first attempt at https://twitter.com/tomekgodzik/status/1363447488653451265?s=21