Skip to content

Commit

Permalink
Fix stack overflows on complex packages (#1383)
Browse files Browse the repository at this point in the history
* fix stack overflows by not recomputing canonical libraries

* dartfmt

* changelog
  • Loading branch information
jcollins-g authored Apr 19, 2017
1 parent afeea82 commit 40938a0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* added a new `--footer-text` command-line option, to allow adding additional
text in the package name and copyright section of the footer
* Reduced stack depth by not recomputing findCanonicalLibraryFor (#1381)

## 0.10.0

Expand Down
4 changes: 2 additions & 2 deletions dartdoc.iml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
Expand Down Expand Up @@ -33,7 +33,7 @@
<excludeFolder url="file://$MODULE_DIR$/tool/packages" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart SDK" level="application" />
</component>
</module>
3 changes: 2 additions & 1 deletion lib/src/html/html_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class HtmlGenerator extends Generator {
static Future<HtmlGenerator> create(
{HtmlGeneratorOptions options,
List<String> headers,
List<String> footers, List<String> footerTexts}) async {
List<String> footers,
List<String> footerTexts}) async {
var templates = await Templates.create(
headerPaths: headers,
footerPaths: footers,
Expand Down
13 changes: 11 additions & 2 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2796,16 +2796,25 @@ class Package implements Nameable, Documentable {
@override
String toString() => isSdk ? 'SDK' : 'Package $name';

final Map<Element, Library> _canonicalLibraryFor = new Map();

/// Tries to find a top level library that references this element.
Library findCanonicalLibraryFor(Element e) {
assert(allLibrariesAdded);

if (_canonicalLibraryFor.containsKey(e)) {
return _canonicalLibraryFor[e];
}
_canonicalLibraryFor[e] = null;
for (Library library in libraries) {
if (library.modelElementsMap.containsKey(e)) {
if (library.modelElementsMap[e].isCanonical) {
return library;
_canonicalLibraryFor[e] = library;
break;
}
}
}
return null;
return _canonicalLibraryFor[e];
}

/// Tries to find a canonical ModelElement for this element.
Expand Down

0 comments on commit 40938a0

Please sign in to comment.