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

Expand analyzer's resolution of Dartdoc comment references #47444

Open
srawlins opened this issue Oct 12, 2021 · 3 comments
Open

Expand analyzer's resolution of Dartdoc comment references #47444

srawlins opened this issue Oct 12, 2021 · 3 comments
Assignees
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@srawlins
Copy link
Member

Currently the set of allowed comment references is very very small. Something like:

  • simple identifier (one word)
  • prefixed identifier (foo.bar), for an import prefix and library-level element pair, for a named constructor, and for a static method

We'll expand the set to include:

  • static method or constructor on a prefixed library element (foo.bar.baz)
  • type literal with type arguments (foo<...>)
  • constructor tear-offs with type arguments (foo.bar<...>), including constructor on a prefixed library-level element
  • function tear-offs with type arguments (foo<...>) for top-level functions and static methods

All identifiers, including type arguments, should be hoverable and jumpable. Dartdoc's comment reference resolution is already separate from analyzer's and supports more expressions; it can be separately updated to match (or use) analyzer's resolution more closely.

This will be accomplished with a new interface, CommentReferableExpression, and a new member on CommentReference, called expression.

Steps to get there:

  1. Add new node; update Identifier, PropertyAccess, TypeLiteral, ConstructorReference, FunctionReference to implement new node; add CommentReferableExpression get expression to CommentReference; deprecate CommentReference.newKeyword and CommentReference.identifier; change implementation of CommentReference.identifier to return expression as Identifier.
  2. Publish and update clients to use expression.
  3. Update resolution to resolve more comment text to resolve to CommentReferences; remove CommentReference.newKeyword and CommentReference.identifier.
@srawlins srawlins added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-ux labels Oct 12, 2021
@srawlins srawlins self-assigned this Oct 12, 2021
@jcollins-g jcollins-g added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Oct 13, 2021
copybara-service bot pushed a commit that referenced this issue Oct 29, 2021
…a CommentReference

* Replace `identifier` field with `expression`, which means deprecating
  `identifier`, redirecting users to `expression`. For now, `expression`
  always returns an Identifier. In a future breaking release, it will
  return other CommentReferableExpressions.
* SimpleIdentifier, PrefixedIdentifier, PropertyAccess,
  ConstructorReference, FunctionReference, and TypeLiteral are all
  CommentReferableExpressions, but support is not implemented yet to
  parse CommentReferences with those contained expressions.

Bug: #47444
Change-Id: I1905afecf3878cd7dca6e275ef0a2ab80500eb4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216320
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
copybara-service bot pushed a commit that referenced this issue Dec 14, 2021
This expands the front_end's and analyzer's support for doc comment
references to include `/// [a.b.c]`. Such a reference must be to a
getter, setter, method, or constructor of a class or extension which
is referenced with an import prefix, such as `[async.Future.value]`.

In the existing support for two words, the two words are named
"prefix" and "token". In a three-word reference, the _first_ word
must be an import prefix, but I've chosen the new names,
"leadingPrefix", "prefix", and "token", to minimize the change.

If an improved change is desirable, considering the names from scratch,
I might choose something like "prefix", "container", and "identifier".
But these names will be applied to one-word and two-word references as
well, so `[async.Future]`, a reference to the Future class provided by
an import prefixed as 'async', would have a 'prefix' of null, a
'container' of 'async', and an identifier of 'Future'.

Bug: #47444
Change-Id: I7758ec16872677221c456dd1dd6dc2a4df0f6102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
@srawlins
Copy link
Member Author

srawlins commented Jul 1, 2024

CC @bwilkerson for any comments.

@srawlins
Copy link
Member Author

CC @eernstg who cited the spec in another recent issue about comment reference resolution.

@eernstg
Copy link
Member

eernstg commented Jul 19, 2024

Right, that would be #56259 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants