Skip to content

Commit 2bedf1e

Browse files
srawlinsCommit Bot
authored and
Commit Bot
committed
Improve UNUSED_ELEMENT documentation
For dart-archive/linter#3513 Change-Id: Ia522fc8958c2c7c48e3366a874ceae28cb9ed6bf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253302 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent fe44e1e commit 2bedf1e

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

pkg/analyzer/messages.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21251,11 +21251,19 @@ HintCode:
2125121251
The analyzer produces this diagnostic when a private declaration isn't
2125221252
referenced in the library that contains the declaration. The following
2125321253
kinds of declarations are analyzed:
21254-
- Private top-level declarations, such as classes, enums, mixins, typedefs,
21255-
top-level variables, and top-level functions
21256-
- Private static and instance methods
21254+
- Private top-level declarations and all of their members
21255+
- Private members of public declarations
2125721256
- Optional parameters of private functions for which a value is never
21258-
passed, even when the parameter doesn't have a private name
21257+
passed
21258+
21259+
Not all references to an element will mark it as "used":
21260+
- Assigning a value to a top-level variable (with a standard `=`
21261+
assignment, or a null-aware `??=` assignment) does not count as using
21262+
it.
21263+
- Refering to an element in a doc comment reference does not count as
21264+
using it.
21265+
- Refering to a class, mixin, or enum in the right side of an `is`
21266+
expression does not count as using it.
2125921267

2126021268
#### Example
2126121269

pkg/analyzer/tool/diagnostics/diagnostics.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19398,11 +19398,19 @@ _The declaration '{0}' isn't referenced._
1939819398
The analyzer produces this diagnostic when a private declaration isn't
1939919399
referenced in the library that contains the declaration. The following
1940019400
kinds of declarations are analyzed:
19401-
- Private top-level declarations, such as classes, enums, mixins, typedefs,
19402-
top-level variables, and top-level functions
19403-
- Private static and instance methods
19401+
- Private top-level declarations and all of their members
19402+
- Private members of public declarations
1940419403
- Optional parameters of private functions for which a value is never
19405-
passed, even when the parameter doesn't have a private name
19404+
passed
19405+
19406+
Not all references to an element will mark it as "used":
19407+
- Assigning a value to a top-level variable (with a standard `=`
19408+
assignment, or a null-aware `??=` assignment) does not count as using
19409+
it.
19410+
- Refering to an element in a doc comment reference does not count as
19411+
using it.
19412+
- Refering to a class, mixin, or enum in the right side of an `is`
19413+
expression does not count as using it.
1940619414

1940719415
#### Example
1940819416

0 commit comments

Comments
 (0)