-
Notifications
You must be signed in to change notification settings - Fork 368
Turn Dotty import suggestions into code actions #2536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
32c7576
to
560081c
Compare
diagnostic.getRange.getEnd() | ||
) | ||
compilers | ||
.autoImports(textDocumentPositionParams, name, token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoImports
aren't yet implemented for Scala 3, so we would have to make do without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I was just thinking about that. The only difficult thing would be to determine import position
@@ -30,4 +30,22 @@ object ScalacDiagnostic { | |||
case _ => None | |||
} | |||
} | |||
|
|||
object SymbolNotFoundWithImportSuggestions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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