| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 engine.incremental_resolver; | 5 library engine.incremental_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart' | 10 import 'package:analyzer/src/context/cache.dart' |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return _assertEquals(elements.length, 0); | 513 return _assertEquals(elements.length, 0); |
| 514 } | 514 } |
| 515 List<FormalParameter> parameters = nodes.parameters; | 515 List<FormalParameter> parameters = nodes.parameters; |
| 516 int length = parameters.length; | 516 int length = parameters.length; |
| 517 _assertEquals(length, elements.length); | 517 _assertEquals(length, elements.length); |
| 518 for (int i = 0; i < length; i++) { | 518 for (int i = 0; i < length; i++) { |
| 519 _assertCompatibleParameter(parameters[i], elements[i]); | 519 _assertCompatibleParameter(parameters[i], elements[i]); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 | 522 |
| 523 /** |
| 524 * Asserts that there is an import with the same prefix as the given |
| 525 * [prefixNode], which exposes the given [element]. |
| 526 */ |
| 527 void _assertElementVisibleWithPrefix( |
| 528 SimpleIdentifier prefixNode, Element element) { |
| 529 if (prefixNode == null) { |
| 530 return; |
| 531 } |
| 532 String prefixName = prefixNode.name; |
| 533 for (ImportElement import in _enclosingLibrary.imports) { |
| 534 if (import.prefix != null && import.prefix.name == prefixName) { |
| 535 Namespace namespace = |
| 536 new NamespaceBuilder().createImportNamespaceForDirective(import); |
| 537 Iterable<Element> visibleElements = namespace.definedNames.values; |
| 538 if (visibleElements.contains(element)) { |
| 539 return; |
| 540 } |
| 541 } |
| 542 } |
| 543 _assertTrue(false); |
| 544 } |
| 545 |
| 523 void _assertEquals(Object a, Object b) { | 546 void _assertEquals(Object a, Object b) { |
| 524 if (a != b) { | 547 if (a != b) { |
| 525 throw new _DeclarationMismatchException(); | 548 throw new _DeclarationMismatchException(); |
| 526 } | 549 } |
| 527 } | 550 } |
| 528 | 551 |
| 529 void _assertFalse(bool condition) { | 552 void _assertFalse(bool condition) { |
| 530 if (condition) { | 553 if (condition) { |
| 531 throw new _DeclarationMismatchException(); | 554 throw new _DeclarationMismatchException(); |
| 532 } | 555 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 _assertEquals(nodeName, 'void'); | 635 _assertEquals(nodeName, 'void'); |
| 613 } else if (type.isDynamic) { | 636 } else if (type.isDynamic) { |
| 614 _assertEquals(nodeName, 'dynamic'); | 637 _assertEquals(nodeName, 'dynamic'); |
| 615 } else { | 638 } else { |
| 616 // TODO(scheglov) support other types | 639 // TODO(scheglov) support other types |
| 617 logger.log('node: $node type: $type type.type: ${type.runtimeType}'); | 640 logger.log('node: $node type: $type type.type: ${type.runtimeType}'); |
| 618 _assertTrue(false); | 641 _assertTrue(false); |
| 619 } | 642 } |
| 620 } | 643 } |
| 621 | 644 |
| 622 /** | |
| 623 * Asserts that there is an import with the same prefix as the given | |
| 624 * [prefixNode], which exposes the given [element]. | |
| 625 */ | |
| 626 void _assertElementVisibleWithPrefix( | |
| 627 SimpleIdentifier prefixNode, Element element) { | |
| 628 if (prefixNode == null) { | |
| 629 return; | |
| 630 } | |
| 631 String prefixName = prefixNode.name; | |
| 632 for (ImportElement import in _enclosingLibrary.imports) { | |
| 633 if (import.prefix != null && import.prefix.name == prefixName) { | |
| 634 Namespace namespace = | |
| 635 new NamespaceBuilder().createImportNamespaceForDirective(import); | |
| 636 Iterable<Element> visibleElements = namespace.definedNames.values; | |
| 637 if (visibleElements.contains(element)) { | |
| 638 return; | |
| 639 } | |
| 640 } | |
| 641 } | |
| 642 _assertTrue(false); | |
| 643 } | |
| 644 | |
| 645 void _assertSameTypeParameter( | 645 void _assertSameTypeParameter( |
| 646 TypeParameter node, TypeParameterElement element) { | 646 TypeParameter node, TypeParameterElement element) { |
| 647 _assertSameType(node.bound, element.bound); | 647 _assertSameType(node.bound, element.bound); |
| 648 } | 648 } |
| 649 | 649 |
| 650 void _assertSameTypeParameters( | 650 void _assertSameTypeParameters( |
| 651 TypeParameterList nodesList, List<TypeParameterElement> elements) { | 651 TypeParameterList nodesList, List<TypeParameterElement> elements) { |
| 652 if (nodesList == null) { | 652 if (nodesList == null) { |
| 653 return _assertEquals(elements.length, 0); | 653 return _assertEquals(elements.length, 0); |
| 654 } | 654 } |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 } | 1464 } |
| 1465 return false; | 1465 return false; |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 CompilationUnit _parseUnit(String code) { | 1468 CompilationUnit _parseUnit(String code) { |
| 1469 LoggingTimer timer = logger.startTimer(); | 1469 LoggingTimer timer = logger.startTimer(); |
| 1470 try { | 1470 try { |
| 1471 Token token = _scan(code); | 1471 Token token = _scan(code); |
| 1472 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1472 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1473 Parser parser = new Parser(_unitSource, errorListener); | 1473 Parser parser = new Parser(_unitSource, errorListener); |
| 1474 AnalysisOptions options = _unitElement.context.analysisOptions; |
| 1475 parser.parseGenericMethods = options.enableGenericMethods; |
| 1474 CompilationUnit unit = parser.parseCompilationUnit(token); | 1476 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 1475 _newParseErrors = errorListener.errors; | 1477 _newParseErrors = errorListener.errors; |
| 1476 return unit; | 1478 return unit; |
| 1477 } finally { | 1479 } finally { |
| 1478 timer.stop('parse'); | 1480 timer.stop('parse'); |
| 1479 } | 1481 } |
| 1480 } | 1482 } |
| 1481 | 1483 |
| 1482 /** | 1484 /** |
| 1483 * Attempts to resolve a documentation comment change. | 1485 * Attempts to resolve a documentation comment change. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 @override | 1996 @override |
| 1995 String toString() => name; | 1997 String toString() => name; |
| 1996 } | 1998 } |
| 1997 | 1999 |
| 1998 class _TokenPair { | 2000 class _TokenPair { |
| 1999 final _TokenDifferenceKind kind; | 2001 final _TokenDifferenceKind kind; |
| 2000 final Token oldToken; | 2002 final Token oldToken; |
| 2001 final Token newToken; | 2003 final Token newToken; |
| 2002 _TokenPair(this.kind, this.oldToken, this.newToken); | 2004 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 2003 } | 2005 } |
| OLD | NEW |