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

Strike out usage of deprecated symbols #309

Open
kpodsiad opened this issue Oct 18, 2022 · 6 comments
Open

Strike out usage of deprecated symbols #309

kpodsiad opened this issue Oct 18, 2022 · 6 comments

Comments

@kpodsiad
Copy link
Member

kpodsiad commented Oct 18, 2022

Is your feature request related to a problem? Please describe.

When I use deprecated method, in completions I see that it's deprecated, but after choosing completion, method is rendered as normal one.

image

Describe the solution you'd like

It should be visible that symbol is deprecated, for instance example from rust:
Screenshot 2022-10-18 at 18 10 36

There is DiagnosticTag for that purpose in diagnostic. I don't know if this can be achieved in other way than through diagnostics.

Describe alternatives you've considered

rely on scalac's deprecation and compilation warnings

  • metals can detect such diagnostics and add deprecated tag to them, will work only if one has this settings enabled on they own
  • metals can implicitly add this setting(?) - but then one will see such diagnostic even if they didn't enable deprecation flag

Additional context

No response

Search terms

deprecation diagnostics

@tgodzik
Copy link
Contributor

tgodzik commented Oct 18, 2022

I was thinking that maybe semantic tokens could help here, but it seems that setting deprecated doesn't do anything currently 🤔 It might depend on the theme? Or maybe something is wrong in the semantic highlight PR? Or the modifier don't do anything right now. Not sure.

The best approach now is to rely on -deprecated flag and add the specific tag to diagnostics. Though we would need to detect is deprecated string, which is not perfect.

@ckipp01
Copy link
Member

ckipp01 commented Oct 18, 2022

Though we would need to detect is deprecated string, which is not perfect.

Note that in Scala 3 everything is there to instead give that diagnostics an errorMessageID and we could just detect that. As of 3.2.x they are being forwarded and Mill and sbt are also forwarding them for us to use.

@tgodzik
Copy link
Contributor

tgodzik commented Oct 18, 2022

Note that in Scala 3 everything is there to instead give that diagnostics an errorMessageID and we could just detect that. As of 3.2.x they are being forwarded and Mill and sbt are also forwarding them for us to use.

Och, we might also need to change that in Bloop. Do you have any links to how it's being handled in sbt?

Coming back to semantic tokens, it does actually work, but is limited by the theme. By doing:

  "editor.semanticTokenColorCustomizations": {
    "[Adapta Nokto]": {
      "rules": {
        "keyword": "#ffffff2f",
        "*.deprecated": {
          "fontStyle": "strikethrough"
        }
      }
    }
  }

I was able to get it to work.

metals-sample-1666112057933

Also changed the color for keyword, which might not have been the best choice 😅

@tgodzik
Copy link
Contributor

tgodzik commented Oct 18, 2022

Plus side of this approach is that we will be able to mark things as deprecated without the additional diagnostics.

@kpodsiad
Copy link
Member Author

kpodsiad commented Oct 18, 2022

@tgodzik will just following work?

"editor.semanticTokenColorCustomizations": {
  "rules": {
    "*.deprecated": {
      "fontStyle": "strikethrough"
    }
  }
}

and if yes, is it possible for extension to contribute to editor settings? 🤔

@ckipp01
Copy link
Member

ckipp01 commented Oct 18, 2022

Och, we might also need to change that in Bloop. Do you have any links to how it's being handled in sbt?

I started work on this in scalacenter/bloop#1750. Everything should be there, but I had some ScalaJS failures that I never had time to look into.

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

No branches or pull requests

3 participants