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

Store comment reference data on ModelNode #3797

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Jun 26, 2024

This is work towards #3798.

The analyzer is now tagging Comment nodes with references with various static elements, all backed by the new @docImport syntax, via a new DocImportScope (see https://dart-review.googlesource.com/c/sdk/+/345361 and https://dart-review.googlesource.com/c/sdk/+/353232). But they're not available in the element model. So while we have the syntax nodes, in PackageGraph, we must "side-car" the data, by storing it in separate classes (with no references to any AST nodes).

So in this change we introduce the CommentReferenceData class, attach instances to ModelNode.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@srawlins
Copy link
Member Author

CC @dart-lang/analyzer-team

Copy link
Member

@bwilkerson bwilkerson left a comment

Choose a reason for hiding this comment

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

LGTM, assuming that the possible overwrite issue isn't really an issue.

}

if (staticElement != null && !data.containsKey(name)) {
data[name] = CommentReferenceData(
Copy link
Member

Choose a reason for hiding this comment

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

I haven't thought about this deeply like I'm sure you have, but at first glance this appears to be prone to having information overwritten if it's possible to have two comment references with the same name that resolve to different elements.

For example, could a reference to a parameter in one method and a parameter with the same name in a different method cause the map to tell us that both references refer to the second method's parameter? Or a similar question about references to type parameters?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! Since this get data is made available on a single Comment, each reference in square brackets with the same name must refer to the same thing. Like in

/// Text [foo] and [bar] and [foo].

There is never a change to the scope within a doc comment, so [foo] and [foo] always refer to the same element.

And then the Map of CommentReferenceData is not merged with any other maps from any other comments. It is just stored in a ModelNode for the documented element.

@srawlins srawlins merged commit 36f1fc7 into dart-lang:main Jun 26, 2024
9 checks passed
@srawlins srawlins deleted the store-comment-reference-data branch June 26, 2024 16:41
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jun 27, 2024
… source_span, stream_channel, term_glyph, tools, vector_math, watcher, webdev, yaml_edit

Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/88df88c..7e5da60):
  7e5da609  2024-06-26  Sam Rawlins  Simplify some end2end tests into smaller tests (dart-lang/dartdoc#3795)
  36f1fc74  2024-06-26  Sam Rawlins  Store comment reference data on ModelNode (dart-lang/dartdoc#3797)
  7ed6ef80  2024-06-24  Sam Rawlins  Hide constructors that cannot be called or referenced by user code (dart-lang/dartdoc#3796)

ecosystem (https://github.com/dart-lang/ecosystem/compare/31148cd..54ca01a):
  54ca01a  2024-06-25  Devon Carew  improvements for transferred issues (dart-lang/ecosystem#274)

html (https://github.com/dart-lang/html/compare/3bc803d..f6c2c71):
  f6c2c71  2024-06-24  Kevin Moore  update lints (dart-archive/html#249)

http (https://github.com/dart-lang/http/compare/4d8e7ef..bf96551):
  bf96551  2024-06-26  Nate Bosch  Call out more limitations of runWithClient (dart-lang/http#1248)
  eb189e1  2024-06-26  Brian Quinlan  [cupertino_http] Fix a bug where content-length was not set for multipart messages (dart-lang/http#1247)
  0bbd166  2024-06-25  Hossein Yousefi  [cronet_http] Upgrade jni and jnigen to 0.9.3 (dart-lang/http#1246)
  dce17c6  2024-06-24  Kevin Moore  misc: add missing packages to root readme (dart-lang/http#1245)
  0b40397  2024-06-24  Kevin Moore  update lints (dart-lang/http#1244)
  2971f32  2024-06-24  Kevin Moore  Update lints (dart-lang/http#1243)
  497bc15  2024-06-24  Parker Lougheed  Update various flutter.dev and dart.dev links (dart-lang/http#1238)
  5f6fcae  2024-06-24  Parker Lougheed  Fix some minor spelling and grammar mistakes (dart-lang/http#1239)
  b7ec613  2024-06-24  Anikate De  pkgs/ok_http: DevTools Networking Support. (dart-lang/http#1242)

json_rpc_2 (https://github.com/dart-lang/json_rpc_2/compare/5b1cbd6..616937f):
  616937f  2024-06-26  Kevin Moore  Update lints, test JS & Wasm (dart-archive/json_rpc_2#116)

mime (https://github.com/dart-lang/mime/compare/4ca2f5e..fd7010b):
  fd7010b  2024-06-24  Kevin Moore  bump lints (dart-archive/mime#127)
  99e9855  2024-06-24  Jonas Finnemann Jensen  Add `topics` to `pubspec.yaml` (dart-archive/mime#121)

mockito (https://github.com/dart-lang/mockito/compare/2302814..9deddcf):
  9deddcf  2024-06-25  Sam Rawlins  Fix lint in examples.
  e99ba54  2024-06-24  Sam Rawlins  Properly generate code for parameter default value Strings.

source_span (https://github.com/dart-lang/source_span/compare/59a3903..89520f3):
  89520f3  2024-06-24  Kevin Moore  bump lints (dart-lang/source_span#114)

stream_channel (https://github.com/dart-lang/stream_channel/compare/b41ff7a..dc620d2):
  dc620d2  2024-06-24  Kevin Moore  bump lints (dart-lang/stream_channel#108)

term_glyph (https://github.com/dart-lang/term_glyph/compare/c86e817..6c2a977):
  6c2a977  2024-06-24  Kevin Moore  bump lints (dart-lang/term_glyph#54)

tools (https://github.com/dart-lang/tools/compare/e660a68..4c60686):
  4c60686  2024-06-24  Christopher Fujino  delete old log file if it exceeds kMaxLogFileSize of 25MiB (dart-lang/tools#277)
  7a231e5  2024-06-24  Parker Lougheed  [unified_analytics] Add lints to consistently use final (dart-lang/tools#278)

vector_math (https://github.com/google/vector_math.dart/compare/e7b11a2..a4304d1):
  a4304d1  2024-06-24  Kevin Moore  Update and fix lints, require Dart 3.1 (google/vector_math.dart#328)
  253f69b  2024-06-24  Kevin Moore  blast_repo fixes (google/vector_math.dart#327)

watcher (https://github.com/dart-lang/watcher/compare/c00fc2a..f312f1f):
  f312f1f  2024-06-24  Kevin Moore  update lints (dart-lang/watcher#169)

webdev (https://github.com/dart-lang/webdev/compare/c566112..75417c0):
  75417c09  2024-06-26  Ben Konyi  Remove remaining MV2 logic (dart-lang/webdev#2453)

yaml_edit (https://github.com/dart-lang/yaml_edit/compare/08a146e..ad3292c):
  ad3292c  2024-06-27  Kavisi  Fix line folding (dart-lang/yaml_edit#87)

Change-Id: Ie2f914dcf97e10cc5a8501c926ddd7e254a0d151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373443
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
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

Successfully merging this pull request may close these issues.

3 participants