@@ -16,10 +16,10 @@ abstract class Canonicalization implements Locatable, Documentable {
16
16
Set <String > get locationPieces;
17
17
18
18
List <ScoredCandidate > scoreCanonicalCandidates (Iterable <Library > libraries) {
19
- return libraries.map (scoreElementWithLibrary ).toList ()..sort ();
19
+ return libraries.map (_scoreElementWithLibrary ).toList ()..sort ();
20
20
}
21
21
22
- ScoredCandidate scoreElementWithLibrary (Library lib) {
22
+ ScoredCandidate _scoreElementWithLibrary (Library lib) {
23
23
var scoredCandidate = ScoredCandidate (this , lib);
24
24
Iterable <String > resplit (Set <String > items) sync * {
25
25
for (var item in items) {
@@ -31,23 +31,23 @@ abstract class Canonicalization implements Locatable, Documentable {
31
31
32
32
// Large boost for @canonicalFor, essentially overriding all other concerns.
33
33
if (lib.canonicalFor.contains (fullyQualifiedName)) {
34
- scoredCandidate.alterScore (5.0 , 'marked @canonicalFor' );
34
+ scoredCandidate._alterScore (5.0 , 'marked @canonicalFor' );
35
35
}
36
36
// Penalty for deprecated libraries.
37
- if (lib.isDeprecated) scoredCandidate.alterScore (- 1.0 , 'is deprecated' );
37
+ if (lib.isDeprecated) scoredCandidate._alterScore (- 1.0 , 'is deprecated' );
38
38
// Give a big boost if the library has the package name embedded in it.
39
39
if (lib.package.namePieces.intersection (lib.namePieces).isEmpty) {
40
- scoredCandidate.alterScore (1.0 , 'embeds package name' );
40
+ scoredCandidate._alterScore (1.0 , 'embeds package name' );
41
41
}
42
42
// Give a tiny boost for libraries with long names, assuming they're
43
43
// 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' );
45
45
// If we don't know the location of this element, return our best guess.
46
46
// TODO(jcollins-g): is that even possible?
47
47
assert (locationPieces.isNotEmpty);
48
48
if (locationPieces.isEmpty) return scoredCandidate;
49
49
// 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 (
51
51
lib.namePieces.intersection (locationPieces).length.toDouble () /
52
52
locationPieces.length.toDouble (),
53
53
'element location shares parts with name' );
@@ -60,35 +60,63 @@ abstract class Canonicalization implements Locatable, Documentable {
60
60
}
61
61
}
62
62
}
63
- scoredCandidate.alterScore (
63
+ scoredCandidate._alterScore (
64
64
scoreBoost, 'element location parts start with parts of name' );
65
65
return scoredCandidate;
66
66
}
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);
67
73
}
68
74
69
75
/// This class represents the score for a particular element; how likely
70
76
/// it is that this is the canonical element.
71
77
class 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;
73
89
74
90
/// 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
+
76
98
final Library library;
77
99
78
100
/// The score accumulated so far. Higher means it is more likely that this
79
101
/// is the intended canonical Library.
80
102
double score = 0.0 ;
81
103
82
- ScoredCandidate (this .element , this .library);
104
+ ScoredCandidate (this ._element , this .library);
83
105
84
- void alterScore (double scoreDelta, String reason) {
106
+ void _alterScore (double scoreDelta, String reason) {
85
107
score += scoreDelta;
86
108
if (scoreDelta != 0 ) {
87
- reasons .add (
109
+ _reasons .add (
88
110
"${reason } (${scoreDelta >= 0 ? '+' : '' }${scoreDelta .toStringAsPrecision (4 )})" );
89
111
}
90
112
}
91
113
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
+
92
120
@override
93
121
int compareTo (ScoredCandidate other) {
94
122
//assert(element == other.element);
@@ -97,5 +125,5 @@ class ScoredCandidate implements Comparable<ScoredCandidate> {
97
125
98
126
@override
99
127
String toString () =>
100
- "${library .name }: ${score .toStringAsPrecision (4 )} - ${reasons .join (', ' )}" ;
128
+ "${library .name }: ${score .toStringAsPrecision (4 )} - ${_reasons .join (', ' )}" ;
101
129
}
0 commit comments