Index: pkg/analyzer/lib/src/task/dart.dart |
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart |
index ff360386f24a8aec8f976b2285f082673b6cf42e..b358fd36c08e77bc0d674ac7f445fcd93a4331c1 100644 |
--- a/pkg/analyzer/lib/src/task/dart.dart |
+++ b/pkg/analyzer/lib/src/task/dart.dart |
@@ -812,6 +812,7 @@ class BuildDirectiveElementsTask extends SourceBasedAnalysisTask { |
importElement.deferred = importDirective.deferredKeyword != null; |
importElement.combinators = _buildCombinators(importDirective); |
importElement.importedLibrary = importedLibrary; |
+ _setDocRange(importElement, importDirective); |
SimpleIdentifier prefixNode = directive.prefix; |
if (prefixNode != null) { |
importElement.prefixOffset = prefixNode.offset; |
@@ -853,6 +854,7 @@ class BuildDirectiveElementsTask extends SourceBasedAnalysisTask { |
exportElement.uri = exportDirective.uriContent; |
exportElement.combinators = _buildCombinators(exportDirective); |
exportElement.exportedLibrary = exportedLibrary; |
+ _setDocRange(exportElement, exportDirective); |
directive.element = exportElement; |
exports.add(exportElement); |
if (exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) { |
@@ -893,6 +895,17 @@ class BuildDirectiveElementsTask extends SourceBasedAnalysisTask { |
} |
/** |
+ * If the given [node] has a documentation comment, remember its range |
+ * into the given [element]. |
+ */ |
+ void _setDocRange(ElementImpl element, AnnotatedNode node) { |
+ Comment comment = node.documentationComment; |
+ if (comment != null && comment.isDocumentation) { |
+ element.setDocRange(comment.offset, comment.length); |
+ } |
+ } |
+ |
+ /** |
* Return a map from the names of the inputs of this kind of task to the task |
* input descriptors describing those inputs for a task with the |
* given library [libSource]. |
@@ -1161,6 +1174,7 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
// |
// Update "part" directives. |
// |
+ LibraryDirective libraryDirective = null; |
LibraryIdentifier libraryNameNode = null; |
String partsLibraryName = _UNKNOWN_LIBRARY_NAME; |
bool hasPartDirective = false; |
@@ -1171,7 +1185,8 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
<CompilationUnitElementImpl>[]; |
for (Directive directive in definingCompilationUnit.directives) { |
if (directive is LibraryDirective) { |
- if (libraryNameNode == null) { |
+ if (libraryDirective == null) { |
+ libraryDirective = directive; |
libraryNameNode = directive.name; |
directivesToResolve.add(directive); |
} |
@@ -1255,6 +1270,9 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
if (sourcedCompilationUnits.isNotEmpty) { |
_patchTopLevelAccessors(libraryElement); |
} |
+ if (libraryDirective != null) { |
+ _setDocRange(libraryElement, libraryDirective); |
+ } |
// |
// Record outputs. |
// |
@@ -1341,6 +1359,17 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
} |
/** |
+ * If the given [node] has a documentation comment, remember its range |
+ * into the given [element]. |
+ */ |
+ void _setDocRange(ElementImpl element, AnnotatedNode node) { |
+ Comment comment = node.documentationComment; |
+ if (comment != null && comment.isDocumentation) { |
+ element.setDocRange(comment.offset, comment.length); |
+ } |
+ } |
+ |
+ /** |
* Return a map from the names of the inputs of this kind of task to the task |
* input descriptors describing those inputs for a task with the given |
* [libSource]. |
@@ -2125,11 +2154,9 @@ class DartErrorsTask extends SourceBasedAnalysisTask { |
String inputName = result.name + '_input'; |
Map<Source, List<AnalysisError>> errorMap = getRequiredInput(inputName); |
for (List<AnalysisError> errors in errorMap.values) { |
- errorLists.add(errors |
- .where((AnalysisError error) { |
- return !filters.any((ErrorFilter filter) => filter(error)); |
- }) |
- .toList()); |
+ errorLists.add(errors.where((AnalysisError error) { |
+ return !filters.any((ErrorFilter filter) => filter(error)); |
+ }).toList()); |
} |
} |
// |