@@ -16,10 +16,10 @@ abstract class Canonicalization implements Locatable, Documentable {
1616 Set <String > get locationPieces;
1717
1818 List <ScoredCandidate > scoreCanonicalCandidates (Iterable <Library > libraries) {
19- return libraries.map (scoreElementWithLibrary ).toList ()..sort ();
19+ return libraries.map (_scoreElementWithLibrary ).toList ()..sort ();
2020 }
2121
22- ScoredCandidate scoreElementWithLibrary (Library lib) {
22+ ScoredCandidate _scoreElementWithLibrary (Library lib) {
2323 var scoredCandidate = ScoredCandidate (this , lib);
2424 Iterable <String > resplit (Set <String > items) sync * {
2525 for (var item in items) {
@@ -31,23 +31,23 @@ abstract class Canonicalization implements Locatable, Documentable {
3131
3232 // Large boost for @canonicalFor, essentially overriding all other concerns.
3333 if (lib.canonicalFor.contains (fullyQualifiedName)) {
34- scoredCandidate.alterScore (5.0 , 'marked @canonicalFor' );
34+ scoredCandidate._alterScore (5.0 , 'marked @canonicalFor' );
3535 }
3636 // Penalty for deprecated libraries.
37- if (lib.isDeprecated) scoredCandidate.alterScore (- 1.0 , 'is deprecated' );
37+ if (lib.isDeprecated) scoredCandidate._alterScore (- 1.0 , 'is deprecated' );
3838 // Give a big boost if the library has the package name embedded in it.
3939 if (lib.package.namePieces.intersection (lib.namePieces).isEmpty) {
40- scoredCandidate.alterScore (1.0 , 'embeds package name' );
40+ scoredCandidate._alterScore (1.0 , 'embeds package name' );
4141 }
4242 // Give a tiny boost for libraries with long names, assuming they're
4343 // more specific (and therefore more likely to be the owner of this symbol).
44- scoredCandidate.alterScore (.01 * lib.namePieces.length, 'name is long' );
44+ scoredCandidate._alterScore (.01 * lib.namePieces.length, 'name is long' );
4545 // If we don't know the location of this element, return our best guess.
4646 // TODO(jcollins-g): is that even possible?
4747 assert (locationPieces.isNotEmpty);
4848 if (locationPieces.isEmpty) return scoredCandidate;
4949 // The more pieces we have of the location in our library name, the more we should boost our score.
50- scoredCandidate.alterScore (
50+ scoredCandidate._alterScore (
5151 lib.namePieces.intersection (locationPieces).length.toDouble () /
5252 locationPieces.length.toDouble (),
5353 'element location shares parts with name' );
@@ -60,35 +60,63 @@ abstract class Canonicalization implements Locatable, Documentable {
6060 }
6161 }
6262 }
63- scoredCandidate.alterScore (
63+ scoredCandidate._alterScore (
6464 scoreBoost, 'element location parts start with parts of name' );
6565 return scoredCandidate;
6666 }
67+
68+ @Deprecated (
69+ 'Public method intended to be private; will be removed as early as '
70+ 'Dartdoc 1.0.0' )
71+ ScoredCandidate scoreElementWithLibrary (Library lib) =>
72+ _scoreElementWithLibrary (lib);
6773}
6874
6975/// This class represents the score for a particular element; how likely
7076/// it is that this is the canonical element.
7177class ScoredCandidate implements Comparable <ScoredCandidate > {
72- final List <String > reasons = [];
78+ final List <String > _reasons = [];
79+
80+ @Deprecated (
81+ 'Public field intended to be private; will be removed as early as '
82+ 'Dartdoc 1.0.0' )
83+ List <String > get reasons => _reasons;
84+
85+ @Deprecated (
86+ 'Public field intended to be private; will be removed as early as '
87+ 'Dartdoc 1.0.0' )
88+ set reasons (List <String > value) => reasons = value;
7389
7490 /// The canonicalization element being scored.
75- final Canonicalization element;
91+ final Canonicalization _element;
92+
93+ @Deprecated (
94+ 'Public getter intended to be private; will be removed as early as '
95+ 'Dartdoc 1.0.0' )
96+ Canonicalization get element => _element;
97+
7698 final Library library;
7799
78100 /// The score accumulated so far. Higher means it is more likely that this
79101 /// is the intended canonical Library.
80102 double score = 0.0 ;
81103
82- ScoredCandidate (this .element , this .library);
104+ ScoredCandidate (this ._element , this .library);
83105
84- void alterScore (double scoreDelta, String reason) {
106+ void _alterScore (double scoreDelta, String reason) {
85107 score += scoreDelta;
86108 if (scoreDelta != 0 ) {
87- reasons .add (
109+ _reasons .add (
88110 "${reason } (${scoreDelta >= 0 ? '+' : '' }${scoreDelta .toStringAsPrecision (4 )})" );
89111 }
90112 }
91113
114+ @Deprecated (
115+ 'Public method intended to be private; will be removed as early as '
116+ 'Dartdoc 1.0.0' )
117+ void alterScore (double scoreDelta, String reason) =>
118+ _alterScore (scoreDelta, reason);
119+
92120 @override
93121 int compareTo (ScoredCandidate other) {
94122 //assert(element == other.element);
@@ -97,5 +125,5 @@ class ScoredCandidate implements Comparable<ScoredCandidate> {
97125
98126 @override
99127 String toString () =>
100- "${library .name }: ${score .toStringAsPrecision (4 )} - ${reasons .join (', ' )}" ;
128+ "${library .name }: ${score .toStringAsPrecision (4 )} - ${_reasons .join (', ' )}" ;
101129}
0 commit comments