[doc_imports] Differences with analyzer and Dartdoc's comment resolver #3762
Labels
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
General Problem
When looking for a reference with the same name as other references in scope, which should the comment reference resolver pick?
For example, this can happen when a class member doc comment references a name that is both a field and a parameter.
Resolution today
Dartdoc has its own algorithm to search through children nodes and parent nodes (universal reference resolving).
This algorithm can be seen in
CommentReferable.referenceBy
.Resolution tomorrow
The analyzer has a different algorithm with
Scope
that makes for (IMO) better reference resolving, but this does mean that there are a couple of differences and changes.I'll list out a bunch of examples where this happens with output from some dummy warnings I've generated.
Case 1: Analyzer prefers parameters over fields.
This should be an acceptable change that the analyzer prefers the
Parameter
. If we want theField
, we should have doc writers write[Class.field]
as an escape hatch.We might need to migrate the references that intend to be referencing fields.
An example of this is below:
https://github.com/dart-lang/sdk/blob/51d7b8477d4abe6cc54b203dcf6fae3a45f0c7db/sdk/lib/convert/html_escape.dart#L141
Case 2: Analyzer prefers a field over parameter.
/flutter/packages/flutter/lib/src/material/theme_data.dart for
[applyElevationOverlayColor]
ThemeData
factory constructor which makes no sense./flutter/packages/flutter/lib/src/material/colors.dart for
[value]
/flutter/packages/flutter/lib/src/foundation/diagnostics.dart for
[hashCode]
Object
which makes more sense than this unrelatedRadioThemeData
hashcode.Bonus Case 3: Analyzer finding references where Dartdoc couldn't before
This is more of a general win.
[File]
in this doc comment wouldn't be linked, but is now linked to the correct class.File
class...The text was updated successfully, but these errors were encountered: