Skip to content

Add unused diagnostic subtype - #49646

Merged
Matt Bierner (mjbvz) merged 2 commits into
masterfrom
unused-grayout
May 17, 2018
Merged

Matt Bierner (mjbvz) merged 2 commits into
masterfrom
unused-grayout

Conversation

@mjbvz

@mjbvz Matt Bierner (mjbvz) commented May 10, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #15710

Adds a new DiagnosticTag class that provide additional information about a diagnostic. Introduce DiagnosticTag.Unnecessary to mark when a diagnostic is for unused / unnecessary code

The design comes from Rosyln's diagnostic object and allows us to modify how a diagnostic is rendered without changing its serverity.

Hooks up JS and TS to use this new tag. This is controlled by the javascript.showUnused.enabled setting which is enabled by default

Alternate design considered

  • Introduce a new diagnostic severity for unused.

    However, using this approach, if a user sets noUnusedLocals in their tsconfig.json, the resulting diagnostic could only show the squiggly OR be grayed out. Using customTags allows us to support both graying out and showing the squiggly

  • Custom JS/TS implementation using decorators

    Not themable. We want a standard experience across languages.

@mjbvz

Matt Bierner (mjbvz) commented May 10, 2018 •

Copy link
Copy Markdown
Contributor Author

Comment thread src/vs/vscode.d.ts Outdated
/**
* Unused or unnecessary code.
*/
Unnecessary = 'unnecessary'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrieken

Copy link
Copy Markdown
Contributor

What other tags do we envision? Any of those used by Roslyn seem very specific: http://source.roslyn.io/#Microsoft.CodeAnalysis/Diagnostic/WellKnownDiagnosticTags.cs,03ef56ba68ffca36,references, in fact I only understand half of them... Is this maybe a dupe of #24682 just with some predefined tags/defaults that we know how to render? Will there be a future with custom rendering of tags?

@jrieken

Johannes Rieken (jrieken) commented May 17, 2018 •

Copy link
Copy Markdown
Contributor

Further questions to seed some disucssion

  • Why do we like TSLint using green squiggles for unused things but don't like that for TypeScript?
  • Do we want DiagnosticSeverity.Hidden to help code actions but do the rendering via some (tbd) semantic highlighting API?

Matt Bierner added 2 commits May 17, 2018 13:03
Fixes #15710

Adds a new `DiagnosticTag` class that provide additional information about a diagnostic. Introduce `DiagnosticTag.Unnecessary` to mark when a diagnostic is for unused / unnecessary code

The design comes from Rosyln's diagnostic object and allows us to modify how a diagnostic is rendered without changing its serverity.

Hooks up JS and TS to use this new tag. This is controlled by the `javascript.showUnused.enabled` setting which is enabled by default

- Introduce a new diagnostic severity for unused.

    However, using this approach, if a user sets `noUnusedLocals` in their `tsconfig.json`, the resulting diagnostic could only show the squiggly OR be grayed out. Using `customTags` allows us to support both graying out and showing the squiggly

- Custom JS/TS implementation using decorators

    Not themable. We want a standard experience across languages.
- Use numeric enum
@mjbvz

Copy link
Copy Markdown
Contributor Author

Merging with proposed api using diagnostic tags. We can revisit this to see if we want try implementing this with a semantic highlighting api next iteration

@mjbvz
Matt Bierner (mjbvz) deleted the unused-grayout branch July 24, 2018 01:11
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Highlight unused symbols

2 participants