Removes the diagnostic codes
`HintCode.deprecatedMemberUseFromSamePackage` and
`HintCode.deprecatedMemberUseFromSamePackageWithMessage`, and the
logic for reporting them. These hint codes have been replaced with
lints.
Removing these diagnostic codes avoids an ambiguity between
`HintCode.deprecatedMemberUseFromSamePackageWithMessage` and
`LinterLintCode.deprecatedMemberUseFromSamePackageWithMessage`.
Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.
In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.
To avoid this change causing `ignore:` comments to become unnecessary
(which would break bots), I've enabled the lint
`deprecated_member_use_from_same_package` in `pkg/analysis_server`,
`pkg/analyzer`, `pkg/compiler`, and `pkg/linter`. After this change
lands, I will work with the owners of those packages to determine
whether it's better to keep the lint enabled or to remove the
`ignore:` comments.
Change-Id: I6a6a6964aa7f69a41b9b815e0f50fc638898f104
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455541
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Fixes trivial typos and adds `@docImport` declarations so that no
dangling comment references remain in the `analyzer` package, and
enables the `comment_references` lint so that dangling comment
references won't be added in the future.
Change-Id: I6a6a696466de07d6a07fe9f0afe875019bc44c71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450743
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Introduce the internal `analyzer_element_model_tracking` lint to enforce
explicit tracking annotations on analyzer element-model members. This
codifies how each member contributes to IDs, dependency tracking, and
incremental analysis.
Rule behavior (applies to classes annotated with `@elementClass`):
- Public instance **fields** must be annotated with
`@trackedIncludedInId`.
- Public instance **getters/methods** (non-abstract, non-void) must have
exactly one of:
`@trackedDirectly`, `@trackedDirectlyExpensive`,
`@trackedDirectlyOpaque`, `@trackedIncludedInId`, or
`@trackedIndirectly`.
- Flags invalid annotations on ineligible members (constructors, setters,
static or private members).
- Reports when more than one tracking annotation is present.
- Reports when a required annotation is missing.
Wire-up:
- Add lint codes and names:
- `analyzer_element_model_tracking_bad`
- `analyzer_element_model_tracking_more_than_one`
- `analyzer_element_model_tracking_zero`
- Mark these as `noFix` in error-fix status and enable the rule in
`analysis_options.yaml`.
- Register the rule in the linter.
Model updates:
- Annotate many members in `element.dart` to reflect their tracking
category (e.g. `@trackedIncludedInId` for identity-affecting members;
`@trackedDirectlyExpensive` for lazily computed collections).
- For opaque surfaces where precise tracking is impractical (e.g.
`documentationComment`, `nonSynthetic`, `session`, member lookups,
ancestor queries, `visitChildren`), record usage via
`globalResultRequirements?.recordOpaqueApiUse(...)`.
Why:
- Makes dependency/ID semantics explicit and reviewable.
- Improves correctness of incremental and cache invalidation behavior.
- Establishes a foundation for refining precision over time without
regressions.
Scope:
- Internal only; no public API changes.
Change-Id: Id2beaf5ead35b8a361bc1b7688ccb5b5a74afe88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446140
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Several call sites intentionally discard a future; these call sites
have been wrapped with `unawaited()` (which is the standard way to
suppress the lint).
Turning on this lint uncovered several tests that should have been
async; these tests have been fixed.
Change-Id: I66e0f6bf7a05946e8d460ce9b5581837ce067870
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431420
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
The new lint, called `analyzer_public_api`, verifies that the analyzer
public API satisfies the following properties:
- No method, function, getter, setter, or supertype in the public API
refers to a non-public type.
- No `export` declaration in the public API shows a non-public name.
- No declaration in the public API has a name ending in `Impl`.
- No file in the public API has a `part` declaration that points to a
file that's not in the public API. (If it did, then the other checks
could be circumvented.)
A new annotation is added, `@AnalyzerPublicApi()`, allowing
declarations in `package:analyzer/src` or
`package:_fe_analyzer_shared/src` to be marked as part of the analyzer
public API. This is necessary because some parts of the analyzer
public API need to be declared elsewhere and then exported by the
analyzer.
A few lint violations have been ignored using `ignore:` comments. I
will try to clean these up in follow-up CLs.
Fixes https://github.com/dart-lang/sdk/issues/60058.
Bug: https://github.com/dart-lang/sdk/issues/60058
Change-Id: I0047a73dec8a29e2ffe03dd3a90f7e41ca2e27b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The analyzer team has decided to adopt the convention of using `TODO`
comments to document long term issues that should persist in the
codebase, and `FIXME` comments to document short term issues that need
immediate attention. They may even consider adding a presubmit hook
to ensure that `FIXME` comments are only used during local
development.
Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there are hundreds of them,
and they're not immediately actionable). This makes VSCode's
"problems" view much more usable in "tree" mode.
Change-Id: I11a0c59132fb98c1c86fb4adf22d1fdf3b547c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Broadly, this _adds_ text to the code, as making something explicit which was previously implicit generally requires adding characters. The fixes are of the form:
* `int x = y /* dynamic */;` --> `var x = y as int;`
* `Map<A, B> x = y; --> `var x = y.cast<A, B>();`
Most of the changes are in code which has parsed YAML or which has parsed arguments. Go figure. :)
Change-Id: I1107688bf4ce9c1ec3ed6a4cef56d4d968048e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278522
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
* Move many identifiers from snake_case or SCREAMING_SNAKE_CASE to
camelCase. I think I restricted the changes to private API.
* Add an ignore in generated files for constant_identifier_names;
we often just mirror names found in YAML files or whatever, where
things are not necessarily named according to Effective Dart
standards.
* Avoid some implementation imports which I think were accidental.
* Use single quotes in some more places.
Bug: https://github.com/dart-lang/sdk/issues/48784
Change-Id: I439fe50cb9f8f8f5e9c74ce594aea15e394ee7da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>