Skip to content

Upgrade analyzer to 0.30 and work around issues #1418

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

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Update analyzer to 0.30. #1403

## 0.11.2
* Fix regression where warnings generated by the README could result in a fatal exception. #1409

Expand Down
16 changes: 7 additions & 9 deletions lib/src/markdown_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ NodeList<CommentReference> _getCommentRefs(Documentable documentable) {
// CommentReference list.
if (documentable is! ModelElement) return null;
ModelElement modelElement = documentable;
Class preferredClass = _getPreferredClass(modelElement);
ModelElement cModelElement = modelElement.package
.findCanonicalModelElementFor(modelElement.element,
preferredClass: preferredClass);
if (cModelElement == null) return null;
modelElement = cModelElement;

if (modelElement.element.documentationComment == null &&
modelElement.canOverride()) {
Expand Down Expand Up @@ -255,16 +249,20 @@ MatchingLinkResult _getMatchingLinkElement(

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

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

Library refLibrary = element.package.findOrCreateLibraryFor(refElement);
Element searchElement =
refElement is Member ? refElement.baseElement : refElement;
Element searchElement = refElement;
if (searchElement is Member)
searchElement = Package.getBasestElement(refElement);

Class preferredClass = _getPreferredClass(element);
ModelElement refModelElement = element.package.findCanonicalModelElementFor(
Expand Down
25 changes: 19 additions & 6 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ abstract class Inheritable {
Element searchElement = element;
if (!_canonicalEnclosingClassIsSet) {
if (isInherited) {
while (searchElement is Member) {
searchElement = (searchElement as Member).baseElement;
}
searchElement = searchElement is Member
? Package.getBasestElement(searchElement)
: searchElement;
bool foundElement = false;
// TODO(jcollins-g): generate warning if an inherited element's definition
// is in an intermediate non-canonical class in the inheritance chain
Expand Down Expand Up @@ -363,8 +363,6 @@ class Class extends ModelElement implements EnclosedElement {
_allElements.addAll(constructors.map((e) => e.element));
_allElements.addAll(staticMethods.map((e) => e.element));
_allElements.addAll(staticProperties.map((e) => e.element));
_allElements.addAll(_allElements.where((e) => e is Member)
..map((e) => (e as Member).baseElement));
}
return _allElements.contains(element);
}
Expand Down Expand Up @@ -1744,7 +1742,9 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
// It isn't a disambiguator because EnumFields are not inherited, ever.
// TODO(jcollins-g): cleanup class hierarchy so that EnumFields aren't
// Inheritable, somehow?
if (e is Member) e = (e as Member).baseElement;
if (e is Member) {
e = Package.getBasestElement(e);
}
Tuple4<Element, Library, Class, ModelElement> key =
new Tuple4(e, library, enclosingClass, enclosingCombo);
ModelElement newModelElement;
Expand Down Expand Up @@ -3313,19 +3313,32 @@ class Package implements Nameable, Documentable {
return _canonicalLibraryFor[e];
}

// TODO(jcollins-g): Revise when dart-lang/sdk#29600 is fixed.
static Element getBasestElement(Member member) {
Element element = member;
while (element is Member) {
element = (element as Member).baseElement;
}
return element;
}

/// Tries to find a canonical ModelElement for this element. If we know
/// this element is related to a particular class, pass preferredClass to
/// disambiguate.
ModelElement findCanonicalModelElementFor(Element e, {Class preferredClass}) {
assert(allLibrariesAdded);
Library lib = findCanonicalLibraryFor(e);
if (lib == null && preferredClass != null) {
lib = findCanonicalLibraryFor(preferredClass.element);
}
ModelElement modelElement;
// TODO(jcollins-g): The data structures should be changed to eliminate guesswork
// with member elements.
if (e is ClassMemberElement || e is PropertyAccessorElement) {
// Prefer Fields over Accessors.
if (e is PropertyAccessorElement)
e = (e as PropertyAccessorElement).variable;
if (e is Member) e = getBasestElement(e);
Set<ModelElement> candidates = new Set();
Tuple2<Element, Library> iKey = new Tuple2(e, lib);
Tuple4<Element, Library, Class, ModelElement> key =
Expand Down
18 changes: 15 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.29.9"
version: "0.30.0"
ansicolor:
description:
name: ansicolor
Expand Down Expand Up @@ -73,6 +73,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
front_end:
description:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-alpha.4"
glob:
description:
name: glob
Expand Down Expand Up @@ -115,6 +121,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
kernel:
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0-alpha.1"
logging:
description:
name: logging
Expand All @@ -132,7 +144,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
version: "0.12.1"
meta:
description:
name: meta
Expand Down Expand Up @@ -282,7 +294,7 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.20+4"
version: "0.12.20+13"
tuple:
description:
name: tuple
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/dartdoc
environment:
sdk: '>=1.14.0 <2.0.0'
dependencies:
analyzer: ^0.29.8
analyzer: ^0.30.0
args: ^0.13.0
collection: ^1.2.0
html: '>=0.12.1 <0.14.0'
Expand Down
2 changes: 1 addition & 1 deletion testing/test_package_docs/fake/SpecialList/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h5>class SpecialList</h5>
function <code>f</code> multiple times on the same element.</p>
<p>Methods on the returned iterable are allowed to omit calling <code>f</code>
on any element where the result isn't needed.
For example, <code>elementAt</code> may call <code>f</code> only once.</p>
For example, <a href="fake/SpecialList/elementAt.html">elementAt</a> may call <code>f</code> only once.</p>
</section>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h5>class SpecialList</h5>
<code>end - start</code>. An empty range (with <code>end == start</code>) is valid.</p>
<p>This method does not work on fixed-length lists, even when <code>replacement</code>
has the same number of elements as the replaced range. In that case use
<code>setRange</code> instead.</p>
<a href="fake/SpecialList/setRange.html">setRange</a> instead.</p>
</section>


Expand Down
2 changes: 1 addition & 1 deletion testing/test_package_docs/fake/SpecialList/take.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
<p>Returns a lazy iterable of the <code>count</code> first elements of this iterable.</p>
<p>The returned <code>Iterable</code> may contain fewer than <code>count</code> elements, if <code>this</code>
contains fewer than <code>count</code> elements.</p>
<p>The elements can be computed by stepping through <code>iterator</code> until <code>count</code>
<p>The elements can be computed by stepping through <a href="fake/SpecialList/iterator.html">iterator</a> until <code>count</code>
elements have been seen.</p>
<p>The <code>count</code> must not be negative.</p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion testing/test_package_docs/fake/SpecialList/takeWhile.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
<p>Returns a lazy iterable of the leading elements satisfying <code>test</code>.</p>
<p>The filtering happens lazily. Every new iterator of the returned
iterable starts iterating over the elements of <code>this</code>.</p>
<p>The elements can be computed by stepping through <code>iterator</code> until an
<p>The elements can be computed by stepping through <a href="fake/SpecialList/iterator.html">iterator</a> until an
element is found where <code>test(element)</code> is false. At that point,
the returned iterable stops (its <code>moveNext()</code> returns false).</p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion testing/test_package_docs/fake/SpecialList/where.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h5>class SpecialList</h5>
<p>Returns a new lazy <code>Iterable</code> with all elements that satisfy the
predicate <code>test</code>.</p>
<p>The matching elements have the same order in the returned iterable
as they have in <code>iterator</code>.</p>
as they have in <a href="fake/SpecialList/iterator.html">iterator</a>.</p>
<p>This method returns a view of the mapped elements.
As long as the returned <code>Iterable</code> is not iterated over,
the supplied function <code>test</code> will not be invoked.
Expand Down