Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1620203006: set LibraryElement documentation to docs of first directive in CU (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: remove unused var Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 definingCompilationUnit.element; 1391 definingCompilationUnit.element;
1392 Map<Source, CompilationUnit> partUnitMap = 1392 Map<Source, CompilationUnit> partUnitMap =
1393 new HashMap<Source, CompilationUnit>(); 1393 new HashMap<Source, CompilationUnit>();
1394 for (CompilationUnit partUnit in partUnits) { 1394 for (CompilationUnit partUnit in partUnits) {
1395 Source partSource = partUnit.element.source; 1395 Source partSource = partUnit.element.source;
1396 partUnitMap[partSource] = partUnit; 1396 partUnitMap[partSource] = partUnit;
1397 } 1397 }
1398 // 1398 //
1399 // Update "part" directives. 1399 // Update "part" directives.
1400 // 1400 //
1401 LibraryDirective libraryDirective = null;
1402 LibraryIdentifier libraryNameNode = null; 1401 LibraryIdentifier libraryNameNode = null;
1403 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; 1402 String partsLibraryName = _UNKNOWN_LIBRARY_NAME;
1404 bool hasPartDirective = false; 1403 bool hasPartDirective = false;
1405 FunctionElement entryPoint = 1404 FunctionElement entryPoint =
1406 _findEntryPoint(definingCompilationUnitElement); 1405 _findEntryPoint(definingCompilationUnitElement);
1407 List<Directive> directivesToResolve = <Directive>[]; 1406 List<Directive> directivesToResolve = <Directive>[];
1408 List<CompilationUnitElementImpl> sourcedCompilationUnits = 1407 List<CompilationUnitElementImpl> sourcedCompilationUnits =
1409 <CompilationUnitElementImpl>[]; 1408 <CompilationUnitElementImpl>[];
1410 for (Directive directive in definingCompilationUnit.directives) { 1409 for (Directive directive in definingCompilationUnit.directives) {
1411 if (directive is LibraryDirective) { 1410 if (directive is LibraryDirective) {
1412 if (libraryDirective == null) { 1411 libraryNameNode = directive.name;
1413 libraryDirective = directive; 1412 directivesToResolve.add(directive);
1414 libraryNameNode = directive.name;
1415 directivesToResolve.add(directive);
1416 }
1417 } else if (directive is PartDirective) { 1413 } else if (directive is PartDirective) {
1418 PartDirective partDirective = directive; 1414 PartDirective partDirective = directive;
1419 StringLiteral partUri = partDirective.uri; 1415 StringLiteral partUri = partDirective.uri;
1420 Source partSource = partDirective.source; 1416 Source partSource = partDirective.source;
1421 hasPartDirective = true; 1417 hasPartDirective = true;
1422 CompilationUnit partUnit = partUnitMap[partSource]; 1418 CompilationUnit partUnit = partUnitMap[partSource];
1423 if (partUnit != null) { 1419 if (partUnit != null) {
1424 CompilationUnitElementImpl partElement = partUnit.element; 1420 CompilationUnitElementImpl partElement = partUnit.element;
1425 partElement.uriOffset = partUri.offset; 1421 partElement.uriOffset = partUri.offset;
1426 partElement.uriEnd = partUri.end; 1422 partElement.uriEnd = partUri.end;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 } 1481 }
1486 LibraryElementImpl libraryElement = 1482 LibraryElementImpl libraryElement =
1487 new LibraryElementImpl.forNode(owningContext, libraryNameNode); 1483 new LibraryElementImpl.forNode(owningContext, libraryNameNode);
1488 libraryElement.definingCompilationUnit = definingCompilationUnitElement; 1484 libraryElement.definingCompilationUnit = definingCompilationUnitElement;
1489 libraryElement.entryPoint = entryPoint; 1485 libraryElement.entryPoint = entryPoint;
1490 libraryElement.parts = sourcedCompilationUnits; 1486 libraryElement.parts = sourcedCompilationUnits;
1491 for (Directive directive in directivesToResolve) { 1487 for (Directive directive in directivesToResolve) {
1492 directive.element = libraryElement; 1488 directive.element = libraryElement;
1493 } 1489 }
1494 BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement); 1490 BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement);
1495 if (libraryDirective != null) { 1491 // set the library documentation to the docs associated with the first
1496 _setDoc(libraryElement, libraryDirective); 1492 // directive in the compilation unit.
1493 if (definingCompilationUnit.directives.isNotEmpty) {
1494 _setDoc(libraryElement, definingCompilationUnit.directives.first);
1497 } 1495 }
1496
1498 // 1497 //
1499 // Record outputs. 1498 // Record outputs.
1500 // 1499 //
1501 outputs[BUILD_LIBRARY_ERRORS] = errors; 1500 outputs[BUILD_LIBRARY_ERRORS] = errors;
1502 outputs[LIBRARY_ELEMENT1] = libraryElement; 1501 outputs[LIBRARY_ELEMENT1] = libraryElement;
1503 outputs[IS_LAUNCHABLE] = entryPoint != null; 1502 outputs[IS_LAUNCHABLE] = entryPoint != null;
1504 } 1503 }
1505 1504
1506 /** 1505 /**
1507 * Return the top-level [FunctionElement] entry point, or `null` if the given 1506 * Return the top-level [FunctionElement] entry point, or `null` if the given
(...skipping 3941 matching lines...) Expand 10 before | Expand all | Expand 10 after
5449 5448
5450 @override 5449 @override
5451 bool moveNext() { 5450 bool moveNext() {
5452 if (_newSources.isEmpty) { 5451 if (_newSources.isEmpty) {
5453 return false; 5452 return false;
5454 } 5453 }
5455 currentTarget = _newSources.removeLast(); 5454 currentTarget = _newSources.removeLast();
5456 return true; 5455 return true;
5457 } 5456 }
5458 } 5457 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698