| OLD | NEW |
| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 void internalPerform() { | 1227 void internalPerform() { |
| 1228 // | 1228 // |
| 1229 // Prepare inputs. | 1229 // Prepare inputs. |
| 1230 // | 1230 // |
| 1231 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 1231 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 1232 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 1232 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 1233 // | 1233 // |
| 1234 // Build the enum members if they have not already been created. | 1234 // Build the enum members if they have not already been created. |
| 1235 // | 1235 // |
| 1236 EnumDeclaration findFirstEnum() { | 1236 EnumDeclaration findFirstEnum() { |
| 1237 for (CompilationUnitMember member in unit.declarations) { | 1237 NodeList<CompilationUnitMember> members = unit.declarations; |
| 1238 int length = members.length; |
| 1239 for (int i = 0; i < length; i++) { |
| 1240 CompilationUnitMember member = members[i]; |
| 1238 if (member is EnumDeclaration) { | 1241 if (member is EnumDeclaration) { |
| 1239 return member; | 1242 return member; |
| 1240 } | 1243 } |
| 1241 } | 1244 } |
| 1242 return null; | 1245 return null; |
| 1243 } | 1246 } |
| 1244 EnumDeclaration firstEnum = findFirstEnum(); | 1247 EnumDeclaration firstEnum = findFirstEnum(); |
| 1245 if (firstEnum != null && firstEnum.element.accessors.isEmpty) { | 1248 if (firstEnum != null && firstEnum.element.accessors.isEmpty) { |
| 1246 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); | 1249 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); |
| 1247 unit.accept(builder); | 1250 unit.accept(builder); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 CompilationUnit definingCompilationUnit = | 1403 CompilationUnit definingCompilationUnit = |
| 1401 getRequiredInput(DEFINING_UNIT_INPUT); | 1404 getRequiredInput(DEFINING_UNIT_INPUT); |
| 1402 List<CompilationUnit> partUnits = getRequiredInput(PARTS_UNIT_INPUT); | 1405 List<CompilationUnit> partUnits = getRequiredInput(PARTS_UNIT_INPUT); |
| 1403 // | 1406 // |
| 1404 // Process inputs. | 1407 // Process inputs. |
| 1405 // | 1408 // |
| 1406 CompilationUnitElementImpl definingCompilationUnitElement = | 1409 CompilationUnitElementImpl definingCompilationUnitElement = |
| 1407 definingCompilationUnit.element; | 1410 definingCompilationUnit.element; |
| 1408 Map<Source, CompilationUnit> partUnitMap = | 1411 Map<Source, CompilationUnit> partUnitMap = |
| 1409 new HashMap<Source, CompilationUnit>(); | 1412 new HashMap<Source, CompilationUnit>(); |
| 1410 for (CompilationUnit partUnit in partUnits) { | 1413 int partLength = partUnits.length; |
| 1414 for (int i = 0; i < partLength; i++) { |
| 1415 CompilationUnit partUnit = partUnits[i]; |
| 1411 Source partSource = partUnit.element.source; | 1416 Source partSource = partUnit.element.source; |
| 1412 partUnitMap[partSource] = partUnit; | 1417 partUnitMap[partSource] = partUnit; |
| 1413 } | 1418 } |
| 1414 // | 1419 // |
| 1415 // Update "part" directives. | 1420 // Update "part" directives. |
| 1416 // | 1421 // |
| 1417 LibraryIdentifier libraryNameNode = null; | 1422 LibraryIdentifier libraryNameNode = null; |
| 1418 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; | 1423 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; |
| 1419 bool hasPartDirective = false; | 1424 bool hasPartDirective = false; |
| 1420 FunctionElement entryPoint = | 1425 FunctionElement entryPoint = |
| 1421 _findEntryPoint(definingCompilationUnitElement); | 1426 _findEntryPoint(definingCompilationUnitElement); |
| 1422 List<Directive> directivesToResolve = <Directive>[]; | 1427 List<Directive> directivesToResolve = <Directive>[]; |
| 1423 List<CompilationUnitElementImpl> sourcedCompilationUnits = | 1428 List<CompilationUnitElementImpl> sourcedCompilationUnits = |
| 1424 <CompilationUnitElementImpl>[]; | 1429 <CompilationUnitElementImpl>[]; |
| 1425 for (Directive directive in definingCompilationUnit.directives) { | 1430 NodeList<Directive> directives = definingCompilationUnit.directives; |
| 1431 int directiveLength = directives.length; |
| 1432 for (int i = 0; i < directiveLength; i++) { |
| 1433 Directive directive = directives[i]; |
| 1426 if (directive is LibraryDirective) { | 1434 if (directive is LibraryDirective) { |
| 1427 libraryNameNode = directive.name; | 1435 libraryNameNode = directive.name; |
| 1428 directivesToResolve.add(directive); | 1436 directivesToResolve.add(directive); |
| 1429 } else if (directive is PartDirective) { | 1437 } else if (directive is PartDirective) { |
| 1430 StringLiteral partUri = directive.uri; | 1438 StringLiteral partUri = directive.uri; |
| 1431 Source partSource = directive.source; | 1439 Source partSource = directive.source; |
| 1432 hasPartDirective = true; | 1440 hasPartDirective = true; |
| 1433 CompilationUnit partUnit = partUnitMap[partSource]; | 1441 CompilationUnit partUnit = partUnitMap[partSource]; |
| 1434 if (partUnit != null) { | 1442 if (partUnit != null) { |
| 1435 CompilationUnitElementImpl partElement = partUnit.element; | 1443 CompilationUnitElementImpl partElement = partUnit.element; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 setElementDocumentationComment( | 1534 setElementDocumentationComment( |
| 1527 libraryElement, definingCompilationUnit.directives.first); | 1535 libraryElement, definingCompilationUnit.directives.first); |
| 1528 } | 1536 } |
| 1529 } | 1537 } |
| 1530 // | 1538 // |
| 1531 // Resolve the relevant directives to the library element. | 1539 // Resolve the relevant directives to the library element. |
| 1532 // | 1540 // |
| 1533 // TODO(brianwilkerson) This updates the state of the AST structures but | 1541 // TODO(brianwilkerson) This updates the state of the AST structures but |
| 1534 // does not associate a new result with it. | 1542 // does not associate a new result with it. |
| 1535 // | 1543 // |
| 1536 for (Directive directive in directivesToResolve) { | 1544 int length = directivesToResolve.length; |
| 1545 for (int i = 0; i < length; i++) { |
| 1546 Directive directive = directivesToResolve[i]; |
| 1537 directive.element = libraryElement; | 1547 directive.element = libraryElement; |
| 1538 } | 1548 } |
| 1539 // | 1549 // |
| 1540 // Record outputs. | 1550 // Record outputs. |
| 1541 // | 1551 // |
| 1542 outputs[BUILD_LIBRARY_ERRORS] = errors; | 1552 outputs[BUILD_LIBRARY_ERRORS] = errors; |
| 1543 outputs[LIBRARY_ELEMENT1] = libraryElement; | 1553 outputs[LIBRARY_ELEMENT1] = libraryElement; |
| 1544 outputs[IS_LAUNCHABLE] = entryPoint != null; | 1554 outputs[IS_LAUNCHABLE] = entryPoint != null; |
| 1545 } | 1555 } |
| 1546 | 1556 |
| 1547 /** | 1557 /** |
| 1548 * Return the top-level [FunctionElement] entry point, or `null` if the given | 1558 * Return the top-level [FunctionElement] entry point, or `null` if the given |
| 1549 * [element] does not define an entry point. | 1559 * [element] does not define an entry point. |
| 1550 */ | 1560 */ |
| 1551 FunctionElement _findEntryPoint(CompilationUnitElementImpl element) { | 1561 FunctionElement _findEntryPoint(CompilationUnitElementImpl element) { |
| 1552 for (FunctionElement function in element.functions) { | 1562 List<FunctionElement> functions = element.functions; |
| 1563 int length = functions.length; |
| 1564 for (int i = 0; i < length; i++) { |
| 1565 FunctionElement function = functions[i]; |
| 1553 if (function.isEntryPoint) { | 1566 if (function.isEntryPoint) { |
| 1554 return function; | 1567 return function; |
| 1555 } | 1568 } |
| 1556 } | 1569 } |
| 1557 return null; | 1570 return null; |
| 1558 } | 1571 } |
| 1559 | 1572 |
| 1560 /** | 1573 /** |
| 1561 * Return the name of the library that the given part is declared to be a | 1574 * Return the name of the library that the given part is declared to be a |
| 1562 * part of, or `null` if the part does not contain a part-of directive. | 1575 * part of, or `null` if the part does not contain a part-of directive. |
| 1563 */ | 1576 */ |
| 1564 String _getPartLibraryName(Source partSource, CompilationUnit partUnit, | 1577 String _getPartLibraryName(Source partSource, CompilationUnit partUnit, |
| 1565 List<Directive> directivesToResolve) { | 1578 List<Directive> directivesToResolve) { |
| 1566 for (Directive directive in partUnit.directives) { | 1579 NodeList<Directive> directives = partUnit.directives; |
| 1580 int length = directives.length; |
| 1581 for (int i = 0; i < length; i++) { |
| 1582 Directive directive = directives[i]; |
| 1567 if (directive is PartOfDirective) { | 1583 if (directive is PartOfDirective) { |
| 1568 directivesToResolve.add(directive); | 1584 directivesToResolve.add(directive); |
| 1569 LibraryIdentifier libraryName = directive.libraryName; | 1585 LibraryIdentifier libraryName = directive.libraryName; |
| 1570 if (libraryName != null) { | 1586 if (libraryName != null) { |
| 1571 return libraryName.name; | 1587 return libraryName.name; |
| 1572 } | 1588 } |
| 1573 } | 1589 } |
| 1574 } | 1590 } |
| 1575 return null; | 1591 return null; |
| 1576 } | 1592 } |
| 1577 | 1593 |
| 1578 /** | 1594 /** |
| 1579 * Return `true` if the given compilation [unit] contains at least one | 1595 * Return `true` if the given compilation [unit] contains at least one |
| 1580 * import directive with a `dart-ext:` URI. | 1596 * import directive with a `dart-ext:` URI. |
| 1581 */ | 1597 */ |
| 1582 bool _hasExtUri(CompilationUnit unit) { | 1598 bool _hasExtUri(CompilationUnit unit) { |
| 1583 for (Directive directive in unit.directives) { | 1599 NodeList<Directive> directives = unit.directives; |
| 1600 int length = directives.length; |
| 1601 for (int i = 0; i < length; i++) { |
| 1602 Directive directive = directives[i]; |
| 1584 if (directive is ImportDirective) { | 1603 if (directive is ImportDirective) { |
| 1585 if (DartUriResolver.isDartExtUri(directive.uriContent)) { | 1604 if (DartUriResolver.isDartExtUri(directive.uriContent)) { |
| 1586 return true; | 1605 return true; |
| 1587 } | 1606 } |
| 1588 } | 1607 } |
| 1589 } | 1608 } |
| 1590 return false; | 1609 return false; |
| 1591 } | 1610 } |
| 1592 | 1611 |
| 1593 /** | 1612 /** |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 // cycle. | 1933 // cycle. |
| 1915 // | 1934 // |
| 1916 ConstantEvaluationEngine constantEvaluationEngine = | 1935 ConstantEvaluationEngine constantEvaluationEngine = |
| 1917 new ConstantEvaluationEngine(typeProvider, context.declaredVariables, | 1936 new ConstantEvaluationEngine(typeProvider, context.declaredVariables, |
| 1918 typeSystem: context.typeSystem); | 1937 typeSystem: context.typeSystem); |
| 1919 if (dependencyCycle == null) { | 1938 if (dependencyCycle == null) { |
| 1920 constantEvaluationEngine.computeConstantValue(constant); | 1939 constantEvaluationEngine.computeConstantValue(constant); |
| 1921 } else { | 1940 } else { |
| 1922 List<ConstantEvaluationTarget> constantsInCycle = | 1941 List<ConstantEvaluationTarget> constantsInCycle = |
| 1923 <ConstantEvaluationTarget>[]; | 1942 <ConstantEvaluationTarget>[]; |
| 1924 for (WorkItem workItem in dependencyCycle) { | 1943 int length = dependencyCycle.length; |
| 1944 for (int i = 0; i < length; i++) { |
| 1945 WorkItem workItem = dependencyCycle[i]; |
| 1925 if (workItem.descriptor == DESCRIPTOR) { | 1946 if (workItem.descriptor == DESCRIPTOR) { |
| 1926 constantsInCycle.add(workItem.target); | 1947 constantsInCycle.add(workItem.target); |
| 1927 } | 1948 } |
| 1928 } | 1949 } |
| 1929 assert(constantsInCycle.isNotEmpty); | 1950 assert(constantsInCycle.isNotEmpty); |
| 1930 constantEvaluationEngine.generateCycleError(constantsInCycle, constant); | 1951 constantEvaluationEngine.generateCycleError(constantsInCycle, constant); |
| 1931 } | 1952 } |
| 1932 // | 1953 // |
| 1933 // Record outputs. | 1954 // Record outputs. |
| 1934 // | 1955 // |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 if (context.analysisOptions.strongMode) { | 2118 if (context.analysisOptions.strongMode) { |
| 2098 LibraryElement library = getRequiredInput(LIBRARY_ELEMENT_INPUT); | 2119 LibraryElement library = getRequiredInput(LIBRARY_ELEMENT_INPUT); |
| 2099 List<LibraryElement> component = library.libraryCycle; | 2120 List<LibraryElement> component = library.libraryCycle; |
| 2100 Set<LibraryElement> filter = new Set<LibraryElement>.from(component); | 2121 Set<LibraryElement> filter = new Set<LibraryElement>.from(component); |
| 2101 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>(); | 2122 Set<CompilationUnitElement> deps = new Set<CompilationUnitElement>(); |
| 2102 void addLibrary(LibraryElement l) { | 2123 void addLibrary(LibraryElement l) { |
| 2103 if (!filter.contains(l)) { | 2124 if (!filter.contains(l)) { |
| 2104 deps.addAll(l.units); | 2125 deps.addAll(l.units); |
| 2105 } | 2126 } |
| 2106 } | 2127 } |
| 2107 for (LibraryElement l in component) { | 2128 int length = component.length; |
| 2108 l.importedLibraries.forEach(addLibrary); | 2129 for (int i = 0; i < length; i++) { |
| 2109 l.exportedLibraries.forEach(addLibrary); | 2130 LibraryElement library = component[i]; |
| 2131 library.importedLibraries.forEach(addLibrary); |
| 2132 library.exportedLibraries.forEach(addLibrary); |
| 2110 } | 2133 } |
| 2111 // | 2134 // |
| 2112 // Record outputs. | 2135 // Record outputs. |
| 2113 // | 2136 // |
| 2114 outputs[LIBRARY_CYCLE] = component; | 2137 outputs[LIBRARY_CYCLE] = component; |
| 2115 outputs[LIBRARY_CYCLE_UNITS] = component.expand((l) => l.units).toList(); | 2138 outputs[LIBRARY_CYCLE_UNITS] = component.expand((l) => l.units).toList(); |
| 2116 outputs[LIBRARY_CYCLE_DEPENDENCIES] = deps.toList(); | 2139 outputs[LIBRARY_CYCLE_DEPENDENCIES] = deps.toList(); |
| 2117 } else { | 2140 } else { |
| 2118 outputs[LIBRARY_CYCLE] = []; | 2141 outputs[LIBRARY_CYCLE] = []; |
| 2119 outputs[LIBRARY_CYCLE_UNITS] = []; | 2142 outputs[LIBRARY_CYCLE_UNITS] = []; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 } | 2401 } |
| 2379 return DeltaResult.KEEP_CONTINUE; | 2402 return DeltaResult.KEEP_CONTINUE; |
| 2380 } | 2403 } |
| 2381 return DeltaResult.INVALIDATE; | 2404 return DeltaResult.INVALIDATE; |
| 2382 } | 2405 } |
| 2383 // Use the target library dependency information to decide whether | 2406 // Use the target library dependency information to decide whether |
| 2384 // the delta affects the library. | 2407 // the delta affects the library. |
| 2385 if (targetSource != null) { | 2408 if (targetSource != null) { |
| 2386 List<Source> librarySources = | 2409 List<Source> librarySources = |
| 2387 context.getLibrariesContaining(targetSource); | 2410 context.getLibrariesContaining(targetSource); |
| 2388 for (Source librarySource in librarySources) { | 2411 int length = librarySources.length; |
| 2412 for (int i = 0; i < length; i++) { |
| 2413 Source librarySource = librarySources[i]; |
| 2389 AnalysisCache cache = context.analysisCache; | 2414 AnalysisCache cache = context.analysisCache; |
| 2390 ReferencedNames referencedNames = | 2415 ReferencedNames referencedNames = |
| 2391 cache.getValue(librarySource, REFERENCED_NAMES); | 2416 cache.getValue(librarySource, REFERENCED_NAMES); |
| 2392 if (referencedNames == null) { | 2417 if (referencedNames == null) { |
| 2393 return DeltaResult.INVALIDATE; | 2418 return DeltaResult.INVALIDATE; |
| 2394 } | 2419 } |
| 2395 referencedNames.addChangedElements(this); | 2420 referencedNames.addChangedElements(this); |
| 2396 if (referencedNames.isAffectedBy(this)) { | 2421 if (referencedNames.isAffectedBy(this)) { |
| 2397 return DeltaResult.INVALIDATE; | 2422 return DeltaResult.INVALIDATE; |
| 2398 } | 2423 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2436 @override | 2461 @override |
| 2437 TaskDescriptor get descriptor => DESCRIPTOR; | 2462 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2438 | 2463 |
| 2439 @override | 2464 @override |
| 2440 void internalPerform() { | 2465 void internalPerform() { |
| 2441 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 2466 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
| 2442 // | 2467 // |
| 2443 // Prepare inputs. | 2468 // Prepare inputs. |
| 2444 // | 2469 // |
| 2445 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin; | 2470 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin; |
| 2446 for (ResultDescriptor result in enginePlugin.dartErrorsForSource) { | 2471 List<ResultDescriptor> errorsForSource = enginePlugin.dartErrorsForSource; |
| 2472 int sourceLength = errorsForSource.length; |
| 2473 for (int i = 0; i < sourceLength; i++) { |
| 2474 ResultDescriptor result = errorsForSource[i]; |
| 2447 String inputName = result.name + '_input'; | 2475 String inputName = result.name + '_input'; |
| 2448 errorLists.add(getRequiredInput(inputName)); | 2476 errorLists.add(getRequiredInput(inputName)); |
| 2449 } | 2477 } |
| 2450 for (ResultDescriptor result in enginePlugin.dartErrorsForUnit) { | 2478 List<ResultDescriptor> errorsForUnit = enginePlugin.dartErrorsForUnit; |
| 2479 int unitLength = errorsForUnit.length; |
| 2480 for (int i = 0; i < unitLength; i++) { |
| 2481 ResultDescriptor result = errorsForUnit[i]; |
| 2451 String inputName = result.name + '_input'; | 2482 String inputName = result.name + '_input'; |
| 2452 Map<Source, List<AnalysisError>> errorMap = getRequiredInput(inputName); | 2483 Map<Source, List<AnalysisError>> errorMap = getRequiredInput(inputName); |
| 2453 for (List<AnalysisError> errors in errorMap.values) { | 2484 for (List<AnalysisError> errors in errorMap.values) { |
| 2454 errorLists.add(errors); | 2485 errorLists.add(errors); |
| 2455 } | 2486 } |
| 2456 } | 2487 } |
| 2457 | 2488 |
| 2458 // | 2489 // |
| 2459 // Filter ignored errors. | 2490 // Filter ignored errors. |
| 2460 // | 2491 // |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2537 * input descriptors describing those inputs for a task with the | 2568 * input descriptors describing those inputs for a task with the |
| 2538 * given [target]. | 2569 * given [target]. |
| 2539 */ | 2570 */ |
| 2540 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2571 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2541 Source source = target; | 2572 Source source = target; |
| 2542 Map<String, TaskInput> inputs = <String, TaskInput>{}; | 2573 Map<String, TaskInput> inputs = <String, TaskInput>{}; |
| 2543 inputs[LINE_INFO_INPUT] = LINE_INFO.of(source); | 2574 inputs[LINE_INFO_INPUT] = LINE_INFO.of(source); |
| 2544 inputs[PARSED_UNIT_INPUT] = PARSED_UNIT.of(source); | 2575 inputs[PARSED_UNIT_INPUT] = PARSED_UNIT.of(source); |
| 2545 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin; | 2576 EnginePlugin enginePlugin = AnalysisEngine.instance.enginePlugin; |
| 2546 // for Source | 2577 // for Source |
| 2547 for (ResultDescriptor result in enginePlugin.dartErrorsForSource) { | 2578 List<ResultDescriptor> errorsForSource = enginePlugin.dartErrorsForSource; |
| 2579 int sourceLength = errorsForSource.length; |
| 2580 for (int i = 0; i < sourceLength; i++) { |
| 2581 ResultDescriptor result = errorsForSource[i]; |
| 2548 String inputName = result.name + '_input'; | 2582 String inputName = result.name + '_input'; |
| 2549 inputs[inputName] = result.of(source); | 2583 inputs[inputName] = result.of(source); |
| 2550 } | 2584 } |
| 2551 // for LibrarySpecificUnit | 2585 // for LibrarySpecificUnit |
| 2552 for (ResultDescriptor result in enginePlugin.dartErrorsForUnit) { | 2586 List<ResultDescriptor> errorsForUnit = enginePlugin.dartErrorsForUnit; |
| 2587 int unitLength = errorsForUnit.length; |
| 2588 for (int i = 0; i < unitLength; i++) { |
| 2589 ResultDescriptor result = errorsForUnit[i]; |
| 2553 String inputName = result.name + '_input'; | 2590 String inputName = result.name + '_input'; |
| 2554 inputs[inputName] = | 2591 inputs[inputName] = |
| 2555 CONTAINING_LIBRARIES.of(source).toMap((Source library) { | 2592 CONTAINING_LIBRARIES.of(source).toMap((Source library) { |
| 2556 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); | 2593 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); |
| 2557 return result.of(unit); | 2594 return result.of(unit); |
| 2558 }); | 2595 }); |
| 2559 } | 2596 } |
| 2560 return inputs; | 2597 return inputs; |
| 2561 } | 2598 } |
| 2562 | 2599 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2929 // | 2966 // |
| 2930 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT); | 2967 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT); |
| 2931 | 2968 |
| 2932 // | 2969 // |
| 2933 // Generate lints. | 2970 // Generate lints. |
| 2934 // | 2971 // |
| 2935 List<AstVisitor> visitors = <AstVisitor>[]; | 2972 List<AstVisitor> visitors = <AstVisitor>[]; |
| 2936 | 2973 |
| 2937 bool timeVisits = analysisOptions.enableTiming; | 2974 bool timeVisits = analysisOptions.enableTiming; |
| 2938 List<Linter> linters = getLints(context); | 2975 List<Linter> linters = getLints(context); |
| 2939 for (Linter linter in linters) { | 2976 int length = linters.length; |
| 2977 for (int i = 0; i < length; i++) { |
| 2978 Linter linter = linters[i]; |
| 2940 AstVisitor visitor = linter.getVisitor(); | 2979 AstVisitor visitor = linter.getVisitor(); |
| 2941 if (visitor != null) { | 2980 if (visitor != null) { |
| 2942 linter.reporter = errorReporter; | 2981 linter.reporter = errorReporter; |
| 2943 if (timeVisits) { | 2982 if (timeVisits) { |
| 2944 visitor = new TimedAstVisitor(visitor, lintRegistry.getTimer(linter)); | 2983 visitor = new TimedAstVisitor(visitor, lintRegistry.getTimer(linter)); |
| 2945 } | 2984 } |
| 2946 visitors.add(visitor); | 2985 visitors.add(visitor); |
| 2947 } | 2986 } |
| 2948 } | 2987 } |
| 2949 | 2988 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3579 parser.parseGenericMethods = options.enableGenericMethods; | 3618 parser.parseGenericMethods = options.enableGenericMethods; |
| 3580 parser.parseGenericMethodComments = options.strongMode; | 3619 parser.parseGenericMethodComments = options.strongMode; |
| 3581 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); | 3620 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); |
| 3582 unit.lineInfo = lineInfo; | 3621 unit.lineInfo = lineInfo; |
| 3583 | 3622 |
| 3584 bool hasNonPartOfDirective = false; | 3623 bool hasNonPartOfDirective = false; |
| 3585 bool hasPartOfDirective = false; | 3624 bool hasPartOfDirective = false; |
| 3586 HashSet<Source> explicitlyImportedSourceSet = new HashSet<Source>(); | 3625 HashSet<Source> explicitlyImportedSourceSet = new HashSet<Source>(); |
| 3587 HashSet<Source> exportedSourceSet = new HashSet<Source>(); | 3626 HashSet<Source> exportedSourceSet = new HashSet<Source>(); |
| 3588 HashSet<Source> includedSourceSet = new HashSet<Source>(); | 3627 HashSet<Source> includedSourceSet = new HashSet<Source>(); |
| 3589 for (Directive directive in unit.directives) { | 3628 NodeList<Directive> directives = unit.directives; |
| 3629 int length = directives.length; |
| 3630 for (int i = 0; i < length; i++) { |
| 3631 Directive directive = directives[i]; |
| 3590 if (directive is PartOfDirective) { | 3632 if (directive is PartOfDirective) { |
| 3591 hasPartOfDirective = true; | 3633 hasPartOfDirective = true; |
| 3592 } else { | 3634 } else { |
| 3593 hasNonPartOfDirective = true; | 3635 hasNonPartOfDirective = true; |
| 3594 if (directive is UriBasedDirective) { | 3636 if (directive is UriBasedDirective) { |
| 3595 Source referencedSource = | 3637 Source referencedSource = |
| 3596 resolveDirective(context, source, directive, errorListener); | 3638 resolveDirective(context, source, directive, errorListener); |
| 3597 if (referencedSource != null) { | 3639 if (referencedSource != null) { |
| 3598 if (directive is ExportDirective) { | 3640 if (directive is ExportDirective) { |
| 3599 exportedSourceSet.add(referencedSource); | 3641 exportedSourceSet.add(referencedSource); |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4659 | 4701 |
| 4660 @override | 4702 @override |
| 4661 void internalPerform() { | 4703 void internalPerform() { |
| 4662 // | 4704 // |
| 4663 // Prepare inputs. | 4705 // Prepare inputs. |
| 4664 // | 4706 // |
| 4665 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | 4707 LibraryElement library = getRequiredInput(LIBRARY_INPUT); |
| 4666 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); | 4708 List<CompilationUnit> units = getRequiredInput(UNITS_INPUT); |
| 4667 // Compute referenced names. | 4709 // Compute referenced names. |
| 4668 ReferencedNames referencedNames = new ReferencedNames(); | 4710 ReferencedNames referencedNames = new ReferencedNames(); |
| 4669 for (CompilationUnit unit in units) { | 4711 int length = units.length; |
| 4670 new ReferencedNamesBuilder(referencedNames).build(unit); | 4712 for (int i = 0; i < length; i++) { |
| 4713 new ReferencedNamesBuilder(referencedNames).build(units[i]); |
| 4671 } | 4714 } |
| 4672 // | 4715 // |
| 4673 // Record outputs. | 4716 // Record outputs. |
| 4674 // | 4717 // |
| 4675 outputs[LIBRARY_ELEMENT9] = library; | 4718 outputs[LIBRARY_ELEMENT9] = library; |
| 4676 outputs[REFERENCED_NAMES] = referencedNames; | 4719 outputs[REFERENCED_NAMES] = referencedNames; |
| 4677 } | 4720 } |
| 4678 | 4721 |
| 4679 /** | 4722 /** |
| 4680 * Return a map from the names of the inputs of this kind of task to the task | 4723 * Return a map from the names of the inputs of this kind of task to the task |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5588 // Record outputs. | 5631 // Record outputs. |
| 5589 // | 5632 // |
| 5590 outputs[VERIFY_ERRORS] = getUniqueErrors(errorListener.errors); | 5633 outputs[VERIFY_ERRORS] = getUniqueErrors(errorListener.errors); |
| 5591 } | 5634 } |
| 5592 | 5635 |
| 5593 /** | 5636 /** |
| 5594 * Check each directive in the given [unit] to see if the referenced source | 5637 * Check each directive in the given [unit] to see if the referenced source |
| 5595 * exists and report an error if it does not. | 5638 * exists and report an error if it does not. |
| 5596 */ | 5639 */ |
| 5597 void validateDirectives(CompilationUnit unit) { | 5640 void validateDirectives(CompilationUnit unit) { |
| 5598 for (Directive directive in unit.directives) { | 5641 NodeList<Directive> directives = unit.directives; |
| 5642 int length = directives.length; |
| 5643 for (int i = 0; i < length; i++) { |
| 5644 Directive directive = directives[i]; |
| 5599 if (directive is UriBasedDirective) { | 5645 if (directive is UriBasedDirective) { |
| 5600 validateReferencedSource(directive); | 5646 validateReferencedSource(directive); |
| 5601 } | 5647 } |
| 5602 } | 5648 } |
| 5603 } | 5649 } |
| 5604 | 5650 |
| 5605 /** | 5651 /** |
| 5606 * Check the given [directive] to see if the referenced source exists and | 5652 * Check the given [directive] to see if the referenced source exists and |
| 5607 * report an error if it does not. | 5653 * report an error if it does not. |
| 5608 */ | 5654 */ |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5710 Source librarySource, this.kind, this.currentResult) { | 5756 Source librarySource, this.kind, this.currentResult) { |
| 5711 _newSources.add(librarySource); | 5757 _newSources.add(librarySource); |
| 5712 } | 5758 } |
| 5713 | 5759 |
| 5714 @override | 5760 @override |
| 5715 void set currentValue(Object value) { | 5761 void set currentValue(Object value) { |
| 5716 LibraryElement library = value; | 5762 LibraryElement library = value; |
| 5717 if (_libraries.add(library)) { | 5763 if (_libraries.add(library)) { |
| 5718 if (kind == _SourceClosureKind.IMPORT || | 5764 if (kind == _SourceClosureKind.IMPORT || |
| 5719 kind == _SourceClosureKind.IMPORT_EXPORT) { | 5765 kind == _SourceClosureKind.IMPORT_EXPORT) { |
| 5720 for (ImportElement importElement in library.imports) { | 5766 List<ImportElement> imports = library.imports; |
| 5767 int length = imports.length; |
| 5768 for (int i = 0; i < length; i++) { |
| 5769 ImportElement importElement = imports[i]; |
| 5721 Source importedSource = importElement.importedLibrary.source; | 5770 Source importedSource = importElement.importedLibrary.source; |
| 5722 _newSources.add(importedSource); | 5771 _newSources.add(importedSource); |
| 5723 } | 5772 } |
| 5724 } | 5773 } |
| 5725 if (kind == _SourceClosureKind.EXPORT || | 5774 if (kind == _SourceClosureKind.EXPORT || |
| 5726 kind == _SourceClosureKind.IMPORT_EXPORT) { | 5775 kind == _SourceClosureKind.IMPORT_EXPORT) { |
| 5727 for (ExportElement exportElement in library.exports) { | 5776 List<ExportElement> exports = library.exports; |
| 5777 int length = exports.length; |
| 5778 for (int i = 0; i < length; i++) { |
| 5779 ExportElement exportElement = exports[i]; |
| 5728 Source exportedSource = exportElement.exportedLibrary.source; | 5780 Source exportedSource = exportElement.exportedLibrary.source; |
| 5729 _newSources.add(exportedSource); | 5781 _newSources.add(exportedSource); |
| 5730 } | 5782 } |
| 5731 } | 5783 } |
| 5732 } | 5784 } |
| 5733 } | 5785 } |
| 5734 | 5786 |
| 5735 @override | 5787 @override |
| 5736 bool get flushOnAccess => false; | 5788 bool get flushOnAccess => false; |
| 5737 | 5789 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5748 | 5800 |
| 5749 @override | 5801 @override |
| 5750 bool moveNext() { | 5802 bool moveNext() { |
| 5751 if (_newSources.isEmpty) { | 5803 if (_newSources.isEmpty) { |
| 5752 return false; | 5804 return false; |
| 5753 } | 5805 } |
| 5754 currentTarget = _newSources.removeLast(); | 5806 currentTarget = _newSources.removeLast(); |
| 5755 return true; | 5807 return true; |
| 5756 } | 5808 } |
| 5757 } | 5809 } |
| OLD | NEW |