Skip to content
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

Actionable diagnostic support #844

Closed
eed3si9n opened this issue May 16, 2023 · 1 comment · Fixed by scala/scala#10406
Closed

Actionable diagnostic support #844

eed3si9n opened this issue May 16, 2023 · 1 comment · Fixed by scala/scala#10406

Comments

@eed3si9n
Copy link
Member

eed3si9n commented May 16, 2023

This is an imple proposal for @ckipp01's Roadmap for actionable diagnostics, which will enable Scala compiler to suggest (semi-automatic) code edits together with compilation errors and warnings, likely useful for things like deprecation and migration warnings.

What's been added to Zinc thus far

  1. Problem#actions - https://github.com/sbt/sbt/blob/v1.9.0-RC3/internal/util-interface/src/main/java/xsbti/Problem.java#L81-L83 (Action contains WorkspaceEdit, which contains TextEdit)
  2. Scala 2.x compiler bridge is now capable of sending Problem#actions since actions follow-up sbt/zinc#1186. As a toy example, it scans for "procedure syntax is deprecated:" in the error message to generate an action.

What I'd like to add to Scala 2.13

  1. Methods in Reporter (https://github.com/scala/scala/blob/v2.13.11-M1/src/reflect/scala/reflect/internal/Reporting.scala#L102) so compiler implementation can report structural code suggestion:
     protected def doReport(pos: Position, msg: String, severity: Severity, force: Boolean, actions: List[Action]): Unit
     final def echo(pos: Position, msg: String, actions: List[Action]): Unit
     final def warning(pos: Position, msg: String, actions: List[Action]): Unit
     final def error(pos: Position, msg: String, actions: List[Action]): Unit
  2. Data structure for Action, WorkspaceEdit, and TextEdit (trait in api + data type in internal).
  3. Add a few actions to deprecations. For example:

Impact to existing users

Hopefully none. The errors and warning message should remain as-is including code examples. Actions will be additional information that compatible editors like IntelliJ and Metals can consume.

@eed3si9n
Copy link
Member Author

here's my PR for this - scala/scala#10406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant