Skip to content

Commit a64f20f

Browse files
authored
Upgrade analyzer to 0.30 and work around issues (#1418)
1 parent 131c556 commit a64f20f

File tree

10 files changed

+49
-24
lines changed

10 files changed

+49
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Update analyzer to 0.30. #1403
2+
13
## 0.11.2
24
* Fix regression where warnings generated by the README could result in a fatal exception. #1409
35

lib/src/markdown_processor.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ NodeList<CommentReference> _getCommentRefs(Documentable documentable) {
169169
// CommentReference list.
170170
if (documentable is! ModelElement) return null;
171171
ModelElement modelElement = documentable;
172-
Class preferredClass = _getPreferredClass(modelElement);
173-
ModelElement cModelElement = modelElement.package
174-
.findCanonicalModelElementFor(modelElement.element,
175-
preferredClass: preferredClass);
176-
if (cModelElement == null) return null;
177-
modelElement = cModelElement;
178172

179173
if (modelElement.element.documentationComment == null &&
180174
modelElement.canOverride()) {
@@ -255,16 +249,20 @@ MatchingLinkResult _getMatchingLinkElement(
255249

256250
// Did not find it anywhere.
257251
if (refElement == null) {
258-
return new MatchingLinkResult(null, null);
252+
// TODO(jcollins-g): remove squelching of non-canonical warnings here
253+
// once we no longer process full markdown for
254+
// oneLineDocs (#1417)
255+
return new MatchingLinkResult(null, null, warn: element.isCanonical);
259256
}
260257

261258
// Ignore all parameters.
262259
if (refElement is ParameterElement || refElement is TypeParameterElement)
263260
return new MatchingLinkResult(null, null, warn: false);
264261

265262
Library refLibrary = element.package.findOrCreateLibraryFor(refElement);
266-
Element searchElement =
267-
refElement is Member ? refElement.baseElement : refElement;
263+
Element searchElement = refElement;
264+
if (searchElement is Member)
265+
searchElement = Package.getBasestElement(refElement);
268266

269267
Class preferredClass = _getPreferredClass(element);
270268
ModelElement refModelElement = element.package.findCanonicalModelElementFor(

lib/src/model.dart

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ abstract class Inheritable {
121121
Element searchElement = element;
122122
if (!_canonicalEnclosingClassIsSet) {
123123
if (isInherited) {
124-
while (searchElement is Member) {
125-
searchElement = (searchElement as Member).baseElement;
126-
}
124+
searchElement = searchElement is Member
125+
? Package.getBasestElement(searchElement)
126+
: searchElement;
127127
bool foundElement = false;
128128
// TODO(jcollins-g): generate warning if an inherited element's definition
129129
// is in an intermediate non-canonical class in the inheritance chain
@@ -363,8 +363,6 @@ class Class extends ModelElement implements EnclosedElement {
363363
_allElements.addAll(constructors.map((e) => e.element));
364364
_allElements.addAll(staticMethods.map((e) => e.element));
365365
_allElements.addAll(staticProperties.map((e) => e.element));
366-
_allElements.addAll(_allElements.where((e) => e is Member)
367-
..map((e) => (e as Member).baseElement));
368366
}
369367
return _allElements.contains(element);
370368
}
@@ -1744,7 +1742,9 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
17441742
// It isn't a disambiguator because EnumFields are not inherited, ever.
17451743
// TODO(jcollins-g): cleanup class hierarchy so that EnumFields aren't
17461744
// Inheritable, somehow?
1747-
if (e is Member) e = (e as Member).baseElement;
1745+
if (e is Member) {
1746+
e = Package.getBasestElement(e);
1747+
}
17481748
Tuple4<Element, Library, Class, ModelElement> key =
17491749
new Tuple4(e, library, enclosingClass, enclosingCombo);
17501750
ModelElement newModelElement;
@@ -3313,19 +3313,32 @@ class Package implements Nameable, Documentable {
33133313
return _canonicalLibraryFor[e];
33143314
}
33153315

3316+
// TODO(jcollins-g): Revise when dart-lang/sdk#29600 is fixed.
3317+
static Element getBasestElement(Member member) {
3318+
Element element = member;
3319+
while (element is Member) {
3320+
element = (element as Member).baseElement;
3321+
}
3322+
return element;
3323+
}
3324+
33163325
/// Tries to find a canonical ModelElement for this element. If we know
33173326
/// this element is related to a particular class, pass preferredClass to
33183327
/// disambiguate.
33193328
ModelElement findCanonicalModelElementFor(Element e, {Class preferredClass}) {
33203329
assert(allLibrariesAdded);
33213330
Library lib = findCanonicalLibraryFor(e);
3331+
if (lib == null && preferredClass != null) {
3332+
lib = findCanonicalLibraryFor(preferredClass.element);
3333+
}
33223334
ModelElement modelElement;
33233335
// TODO(jcollins-g): The data structures should be changed to eliminate guesswork
33243336
// with member elements.
33253337
if (e is ClassMemberElement || e is PropertyAccessorElement) {
33263338
// Prefer Fields over Accessors.
33273339
if (e is PropertyAccessorElement)
33283340
e = (e as PropertyAccessorElement).variable;
3341+
if (e is Member) e = getBasestElement(e);
33293342
Set<ModelElement> candidates = new Set();
33303343
Tuple2<Element, Library> iKey = new Tuple2(e, lib);
33313344
Tuple4<Element, Library, Class, ModelElement> key =

pubspec.lock

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ packages:
66
name: analyzer
77
url: "https://pub.dartlang.org"
88
source: hosted
9-
version: "0.29.9"
9+
version: "0.30.0"
1010
ansicolor:
1111
description:
1212
name: ansicolor
@@ -73,6 +73,12 @@ packages:
7373
url: "https://pub.dartlang.org"
7474
source: hosted
7575
version: "0.13.4"
76+
front_end:
77+
description:
78+
name: front_end
79+
url: "https://pub.dartlang.org"
80+
source: hosted
81+
version: "0.1.0-alpha.4"
7682
glob:
7783
description:
7884
name: glob
@@ -115,6 +121,12 @@ packages:
115121
url: "https://pub.dartlang.org"
116122
source: hosted
117123
version: "1.0.0"
124+
kernel:
125+
description:
126+
name: kernel
127+
url: "https://pub.dartlang.org"
128+
source: hosted
129+
version: "0.3.0-alpha.1"
118130
logging:
119131
description:
120132
name: logging
@@ -132,7 +144,7 @@ packages:
132144
name: matcher
133145
url: "https://pub.dartlang.org"
134146
source: hosted
135-
version: "0.12.0+2"
147+
version: "0.12.1"
136148
meta:
137149
description:
138150
name: meta
@@ -282,7 +294,7 @@ packages:
282294
name: test
283295
url: "https://pub.dartlang.org"
284296
source: hosted
285-
version: "0.12.20+4"
297+
version: "0.12.20+13"
286298
tuple:
287299
description:
288300
name: tuple

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/dartdoc
77
environment:
88
sdk: '>=1.14.0 <2.0.0'
99
dependencies:
10-
analyzer: ^0.29.8
10+
analyzer: ^0.30.0
1111
args: ^0.13.0
1212
collection: ^1.2.0
1313
html: '>=0.12.1 <0.14.0'

testing/test_package_docs/fake/SpecialList/map.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ <h5>class SpecialList</h5>
156156
function <code>f</code> multiple times on the same element.</p>
157157
<p>Methods on the returned iterable are allowed to omit calling <code>f</code>
158158
on any element where the result isn't needed.
159-
For example, <code>elementAt</code> may call <code>f</code> only once.</p>
159+
For example, <a href="fake/SpecialList/elementAt.html">elementAt</a> may call <code>f</code> only once.</p>
160160
</section>
161161

162162

testing/test_package_docs/fake/SpecialList/replaceRange.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h5>class SpecialList</h5>
159159
<code>end - start</code>. An empty range (with <code>end == start</code>) is valid.</p>
160160
<p>This method does not work on fixed-length lists, even when <code>replacement</code>
161161
has the same number of elements as the replaced range. In that case use
162-
<code>setRange</code> instead.</p>
162+
<a href="fake/SpecialList/setRange.html">setRange</a> instead.</p>
163163
</section>
164164

165165

testing/test_package_docs/fake/SpecialList/take.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
150150
<p>Returns a lazy iterable of the <code>count</code> first elements of this iterable.</p>
151151
<p>The returned <code>Iterable</code> may contain fewer than <code>count</code> elements, if <code>this</code>
152152
contains fewer than <code>count</code> elements.</p>
153-
<p>The elements can be computed by stepping through <code>iterator</code> until <code>count</code>
153+
<p>The elements can be computed by stepping through <a href="fake/SpecialList/iterator.html">iterator</a> until <code>count</code>
154154
elements have been seen.</p>
155155
<p>The <code>count</code> must not be negative.</p>
156156
</section>

testing/test_package_docs/fake/SpecialList/takeWhile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
150150
<p>Returns a lazy iterable of the leading elements satisfying <code>test</code>.</p>
151151
<p>The filtering happens lazily. Every new iterator of the returned
152152
iterable starts iterating over the elements of <code>this</code>.</p>
153-
<p>The elements can be computed by stepping through <code>iterator</code> until an
153+
<p>The elements can be computed by stepping through <a href="fake/SpecialList/iterator.html">iterator</a> until an
154154
element is found where <code>test(element)</code> is false. At that point,
155155
the returned iterable stops (its <code>moveNext()</code> returns false).</p>
156156
</section>

testing/test_package_docs/fake/SpecialList/where.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
150150
<p>Returns a new lazy <code>Iterable</code> with all elements that satisfy the
151151
predicate <code>test</code>.</p>
152152
<p>The matching elements have the same order in the returned iterable
153-
as they have in <code>iterator</code>.</p>
153+
as they have in <a href="fake/SpecialList/iterator.html">iterator</a>.</p>
154154
<p>This method returns a view of the mapped elements.
155155
As long as the returned <code>Iterable</code> is not iterated over,
156156
the supplied function <code>test</code> will not be invoked.

0 commit comments

Comments
 (0)