[M] Change in dart/sdk[main]: [DAS] Fixes occurrences for declaring parameters

0 views
Skip to first unread message

FMorschel (Gerrit)

unread,
Apr 21, 2026, 4:22:35 PM (19 hours ago) Apr 21
to dart-analys...@google.com, rev...@dartlang.org

FMorschel has uploaded the change for review

Commit message

[DAS] Fixes occurrences for declaring parameters
Change-Id: Ie94f23da1c47d393124491c37a6098ac66c581b4

Change information

Files:
  • M pkg/analysis_server/lib/src/computer/computer_document_highlights.dart
  • M pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
  • M pkg/analysis_server/lib/src/utilities/extensions/element.dart
  • M pkg/analysis_server/test/analysis/notification_occurrences_test.dart
  • M pkg/analysis_server/test/lsp/document_highlights_test.dart
Change size: M
Delta: 5 files changed, 187 insertions(+), 36 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie94f23da1c47d393124491c37a6098ac66c581b4
Gerrit-Change-Number: 497103
Gerrit-PatchSet: 1
Gerrit-Owner: FMorschel <g...@fmorschel.dev>
Gerrit-Reviewer: FMorschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Danny Tuppeny (Gerrit)

unread,
5:16 AM (6 hours ago) 5:16 AM
to FMorschel, Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson, FMorschel and Samuel Rawlins

Danny Tuppeny added 6 comments

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Danny Tuppeny . resolved

Thanks for looking at this!

File pkg/analysis_server/lib/src/computer/computer_document_highlights.dart
Line 75, Patchset 1 (Latest): // For pattern variables in implicit pattern fields (where the field name
// is inferred from the variable name), also include the field element.
Danny Tuppeny . unresolved

I think this comment is a bit disconnected from the code it relates to now (the existing blank line probably didn't help), it should probably go above `VariablePattern(` on line 85.

Line 505, Patchset 1 (Latest): return _targetElements.any(
(element) => element.name == canonicalElement.name,
);
Danny Tuppeny . unresolved

Is there a reason we can't keep `_elementName` here (even if we capture it in the .elements()` constructor)? This method is called a lot and I'd expect a string comparison is much faster than iterating over even a small list.

File pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
Line 270, Patchset 1 (Latest): _addOccurrence(field, nameToken);
Danny Tuppeny . unresolved

Would we not also need to add `element` here (so that if you start from the parameter name in an invocation, it still matches here?)

File pkg/analysis_server/lib/src/utilities/extensions/element.dart
Line 28, Patchset 1 (Latest): Element? get canonical => switch (this) {
Danny Tuppeny . unresolved

I wonder if this logic is general enough that it's worth extracting from the occurrences code to here? If it might be useful elsewhere, I think it makes sense, but if the rules for canonicalizing are likely to be feature-specific, it might be confusing to have here.

(if the goal was just to share between LSP + legacy, I wouldn't worry too much - legacy occurrences are completely unused and likely to be removed - https://github.com/dart-lang/sdk/issues/60043)

File pkg/analysis_server/test/lsp/document_highlights_test.dart
Line 1400, Patchset 1 (Latest): test_primaryConstructor_declaringPrivateParameter_declaration() async {
Danny Tuppeny . unresolved

I'm not sure how this test differs from the one above? (the code is slightly different, but it seems like they're testing the same - should they be combined?)

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • FMorschel
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ie94f23da1c47d393124491c37a6098ac66c581b4
Gerrit-Change-Number: 497103
Gerrit-PatchSet: 1
Gerrit-Owner: FMorschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: FMorschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-CC: Danny Tuppeny <da...@tuppeny.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: FMorschel <g...@fmorschel.dev>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Wed, 22 Apr 2026 09:16:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages