| 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/resolution_accessors.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 11 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/dart/ast/visitor.dart'; | 12 import 'package:analyzer/dart/ast/visitor.dart'; |
| 12 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
| 13 import 'package:analyzer/dart/element/type.dart'; | 14 import 'package:analyzer/dart/element/type.dart'; |
| 14 import 'package:analyzer/error/error.dart'; | 15 import 'package:analyzer/error/error.dart'; |
| 15 import 'package:analyzer/error/listener.dart'; | 16 import 'package:analyzer/error/listener.dart'; |
| 16 import 'package:analyzer/exception/exception.dart'; | 17 import 'package:analyzer/exception/exception.dart'; |
| 17 import 'package:analyzer/src/context/cache.dart'; | 18 import 'package:analyzer/src/context/cache.dart'; |
| 18 import 'package:analyzer/src/dart/ast/ast.dart' | 19 import 'package:analyzer/src/dart/ast/ast.dart' |
| 19 show NamespaceDirectiveImpl, UriBasedDirectiveImpl, UriValidationCode; | 20 show NamespaceDirectiveImpl, UriBasedDirectiveImpl, UriValidationCode; |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 for (int i = 0; i < length; i++) { | 1322 for (int i = 0; i < length; i++) { |
| 1322 CompilationUnitMember member = members[i]; | 1323 CompilationUnitMember member = members[i]; |
| 1323 if (member is EnumDeclaration) { | 1324 if (member is EnumDeclaration) { |
| 1324 return member; | 1325 return member; |
| 1325 } | 1326 } |
| 1326 } | 1327 } |
| 1327 return null; | 1328 return null; |
| 1328 } | 1329 } |
| 1329 | 1330 |
| 1330 EnumDeclaration firstEnum = findFirstEnum(); | 1331 EnumDeclaration firstEnum = findFirstEnum(); |
| 1331 if (firstEnum != null && firstEnum.element.accessors.isEmpty) { | 1332 if (firstEnum != null && |
| 1333 elementForEnumDeclaration(firstEnum).accessors.isEmpty) { |
| 1332 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); | 1334 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); |
| 1333 unit.accept(builder); | 1335 unit.accept(builder); |
| 1334 } | 1336 } |
| 1335 // | 1337 // |
| 1336 // Record outputs. | 1338 // Record outputs. |
| 1337 // | 1339 // |
| 1338 outputs[CREATED_RESOLVED_UNIT3] = true; | 1340 outputs[CREATED_RESOLVED_UNIT3] = true; |
| 1339 outputs[RESOLVED_UNIT3] = unit; | 1341 outputs[RESOLVED_UNIT3] = unit; |
| 1340 } | 1342 } |
| 1341 | 1343 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 // | 1498 // |
| 1497 // Process inputs. | 1499 // Process inputs. |
| 1498 // | 1500 // |
| 1499 CompilationUnitElementImpl definingCompilationUnitElement = | 1501 CompilationUnitElementImpl definingCompilationUnitElement = |
| 1500 definingCompilationUnit.element; | 1502 definingCompilationUnit.element; |
| 1501 Map<Source, CompilationUnit> partUnitMap = | 1503 Map<Source, CompilationUnit> partUnitMap = |
| 1502 new HashMap<Source, CompilationUnit>(); | 1504 new HashMap<Source, CompilationUnit>(); |
| 1503 int partLength = partUnits.length; | 1505 int partLength = partUnits.length; |
| 1504 for (int i = 0; i < partLength; i++) { | 1506 for (int i = 0; i < partLength; i++) { |
| 1505 CompilationUnit partUnit = partUnits[i]; | 1507 CompilationUnit partUnit = partUnits[i]; |
| 1506 Source partSource = partUnit.element.source; | 1508 Source partSource = elementForCompilationUnit(partUnit).source; |
| 1507 partUnitMap[partSource] = partUnit; | 1509 partUnitMap[partSource] = partUnit; |
| 1508 } | 1510 } |
| 1509 // | 1511 // |
| 1510 // Update "part" directives. | 1512 // Update "part" directives. |
| 1511 // | 1513 // |
| 1512 LibraryIdentifier libraryNameNode = null; | 1514 LibraryIdentifier libraryNameNode = null; |
| 1513 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; | 1515 String partsLibraryName = _UNKNOWN_LIBRARY_NAME; |
| 1514 bool hasPartDirective = false; | 1516 bool hasPartDirective = false; |
| 1515 Set<Source> seenPartSources = new Set<Source>(); | 1517 Set<Source> seenPartSources = new Set<Source>(); |
| 1516 FunctionElement entryPoint = | 1518 FunctionElement entryPoint = |
| (...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3438 void internalPerform() { | 3440 void internalPerform() { |
| 3439 // | 3441 // |
| 3440 // Prepare inputs. | 3442 // Prepare inputs. |
| 3441 // | 3443 // |
| 3442 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 3444 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 3443 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 3445 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 3444 // | 3446 // |
| 3445 // Infer instance members. | 3447 // Infer instance members. |
| 3446 // | 3448 // |
| 3447 if (context.analysisOptions.strongMode) { | 3449 if (context.analysisOptions.strongMode) { |
| 3448 InstanceMemberInferrer inferrer = new InstanceMemberInferrer( | 3450 InstanceMemberInferrer inferrer = new InstanceMemberInferrer(typeProvider, |
| 3449 typeProvider, new InheritanceManager(unit.element.library), | 3451 new InheritanceManager(elementForCompilationUnit(unit).library), |
| 3450 typeSystem: context.typeSystem); | 3452 typeSystem: context.typeSystem); |
| 3451 inferrer.inferCompilationUnit(unit.element); | 3453 inferrer.inferCompilationUnit(unit.element); |
| 3452 } | 3454 } |
| 3453 // | 3455 // |
| 3454 // Record outputs. | 3456 // Record outputs. |
| 3455 // | 3457 // |
| 3456 outputs[RESOLVED_UNIT10] = unit; | 3458 outputs[RESOLVED_UNIT10] = unit; |
| 3457 outputs[CREATED_RESOLVED_UNIT10] = true; | 3459 outputs[CREATED_RESOLVED_UNIT10] = true; |
| 3458 } | 3460 } |
| 3459 | 3461 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 /** | 3506 /** |
| 3505 * Return the declaration of the target within the given compilation [unit]. | 3507 * Return the declaration of the target within the given compilation [unit]. |
| 3506 * Throw an exception if the declaration cannot be found. | 3508 * Throw an exception if the declaration cannot be found. |
| 3507 */ | 3509 */ |
| 3508 VariableDeclaration getDeclaration(CompilationUnit unit) { | 3510 VariableDeclaration getDeclaration(CompilationUnit unit) { |
| 3509 VariableElement variable = target; | 3511 VariableElement variable = target; |
| 3510 int offset = variable.nameOffset; | 3512 int offset = variable.nameOffset; |
| 3511 AstNode node = new NodeLocator2(offset).searchWithin(unit); | 3513 AstNode node = new NodeLocator2(offset).searchWithin(unit); |
| 3512 if (node == null) { | 3514 if (node == null) { |
| 3513 Source variableSource = variable.source; | 3515 Source variableSource = variable.source; |
| 3514 Source unitSource = unit.element.source; | 3516 Source unitSource = elementForCompilationUnit(unit).source; |
| 3515 if (variableSource != unitSource) { | 3517 if (variableSource != unitSource) { |
| 3516 throw new AnalysisException( | 3518 throw new AnalysisException( |
| 3517 "Failed to find the AST node for the variable " | 3519 "Failed to find the AST node for the variable " |
| 3518 "${variable.displayName} at $offset in $variableSource " | 3520 "${variable.displayName} at $offset in $variableSource " |
| 3519 "because we were looking in $unitSource"); | 3521 "because we were looking in $unitSource"); |
| 3520 } | 3522 } |
| 3521 throw new AnalysisException( | 3523 throw new AnalysisException( |
| 3522 "Failed to find the AST node for the variable " | 3524 "Failed to find the AST node for the variable " |
| 3523 "${variable.displayName} at $offset in $variableSource"); | 3525 "${variable.displayName} at $offset in $variableSource"); |
| 3524 } | 3526 } |
| 3525 VariableDeclaration declaration = | 3527 VariableDeclaration declaration = |
| 3526 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); | 3528 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); |
| 3527 if (declaration == null || declaration.name != node) { | 3529 if (declaration == null || declaration.name != node) { |
| 3528 Source variableSource = variable.source; | 3530 Source variableSource = variable.source; |
| 3529 Source unitSource = unit.element.source; | 3531 Source unitSource = elementForCompilationUnit(unit).source; |
| 3530 if (variableSource != unitSource) { | 3532 if (variableSource != unitSource) { |
| 3531 if (declaration == null) { | 3533 if (declaration == null) { |
| 3532 throw new AnalysisException( | 3534 throw new AnalysisException( |
| 3533 "Failed to find the declaration of the variable " | 3535 "Failed to find the declaration of the variable " |
| 3534 "${variable.displayName} at $offset in $variableSource " | 3536 "${variable.displayName} at $offset in $variableSource " |
| 3535 "because the node was not in a variable declaration " | 3537 "because the node was not in a variable declaration " |
| 3536 "possibly because we were looking in $unitSource"); | 3538 "possibly because we were looking in $unitSource"); |
| 3537 } | 3539 } |
| 3538 throw new AnalysisException( | 3540 throw new AnalysisException( |
| 3539 "Failed to find the declaration of the variable " | 3541 "Failed to find the declaration of the variable " |
| (...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6488 | 6490 |
| 6489 @override | 6491 @override |
| 6490 bool moveNext() { | 6492 bool moveNext() { |
| 6491 if (_newSources.isEmpty) { | 6493 if (_newSources.isEmpty) { |
| 6492 return false; | 6494 return false; |
| 6493 } | 6495 } |
| 6494 currentTarget = _newSources.removeLast(); | 6496 currentTarget = _newSources.removeLast(); |
| 6495 return true; | 6497 return true; |
| 6496 } | 6498 } |
| 6497 } | 6499 } |
| OLD | NEW |