| 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 analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 var y = element.map(toSpan); | 315 var y = element.map(toSpan); |
| 316 } | 316 } |
| 317 return null; | 317 return null; |
| 318 }'''); | 318 }'''); |
| 319 expectIdentifierType('y = ', 'dynamic', 'List<dynamic>'); | 319 expectIdentifierType('y = ', 'dynamic', 'List<dynamic>'); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 @reflectiveTest | 323 @reflectiveTest |
| 324 class LibraryImportScopeTest extends ResolverTestCase { | 324 class LibraryImportScopeTest extends ResolverTestCase { |
| 325 void test_conflictingImports() { | |
| 326 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | |
| 327 String typeNameA = "A"; | |
| 328 String typeNameB = "B"; | |
| 329 String typeNameC = "C"; | |
| 330 ClassElement typeA = ElementFactory.classElement2(typeNameA); | |
| 331 ClassElement typeB1 = ElementFactory.classElement2(typeNameB); | |
| 332 ClassElement typeB2 = ElementFactory.classElement2(typeNameB); | |
| 333 ClassElement typeC = ElementFactory.classElement2(typeNameC); | |
| 334 LibraryElement importedLibrary1 = createTestLibrary(context, "imported1"); | |
| 335 (importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl) | |
| 336 .types = <ClassElement>[typeA, typeB1]; | |
| 337 ImportElementImpl import1 = | |
| 338 ElementFactory.importFor(importedLibrary1, null); | |
| 339 LibraryElement importedLibrary2 = createTestLibrary(context, "imported2"); | |
| 340 (importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl) | |
| 341 .types = <ClassElement>[typeB2, typeC]; | |
| 342 ImportElementImpl import2 = | |
| 343 ElementFactory.importFor(importedLibrary2, null); | |
| 344 LibraryElementImpl importingLibrary = | |
| 345 createTestLibrary(context, "importing"); | |
| 346 importingLibrary.imports = <ImportElement>[import1, import2]; | |
| 347 { | |
| 348 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 349 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | |
| 350 expect(scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary), | |
| 351 typeA); | |
| 352 errorListener.assertNoErrors(); | |
| 353 expect(scope.lookup(AstFactory.identifier3(typeNameC), importingLibrary), | |
| 354 typeC); | |
| 355 errorListener.assertNoErrors(); | |
| 356 Element element = | |
| 357 scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary); | |
| 358 errorListener.assertErrorsWithCodes([StaticWarningCode.AMBIGUOUS_IMPORT]); | |
| 359 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, | |
| 360 MultiplyDefinedElement, element); | |
| 361 List<Element> conflictingElements = | |
| 362 (element as MultiplyDefinedElement).conflictingElements; | |
| 363 expect(conflictingElements, hasLength(2)); | |
| 364 if (identical(conflictingElements[0], typeB1)) { | |
| 365 expect(conflictingElements[1], same(typeB2)); | |
| 366 } else if (identical(conflictingElements[0], typeB2)) { | |
| 367 expect(conflictingElements[1], same(typeB1)); | |
| 368 } else { | |
| 369 expect(conflictingElements[0], same(typeB1)); | |
| 370 } | |
| 371 } | |
| 372 { | |
| 373 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 374 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | |
| 375 Identifier identifier = AstFactory.identifier3(typeNameB); | |
| 376 AstFactory.methodDeclaration(null, AstFactory.typeName3(identifier), null, | |
| 377 null, AstFactory.identifier3("foo"), null); | |
| 378 Element element = scope.lookup(identifier, importingLibrary); | |
| 379 errorListener.assertErrorsWithCodes([StaticWarningCode.AMBIGUOUS_IMPORT]); | |
| 380 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, | |
| 381 MultiplyDefinedElement, element); | |
| 382 } | |
| 383 } | |
| 384 | |
| 385 void test_creation_empty() { | 325 void test_creation_empty() { |
| 386 LibraryElement definingLibrary = createDefaultTestLibrary(); | 326 new LibraryImportScope(createDefaultTestLibrary()); |
| 387 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 388 new LibraryImportScope(definingLibrary, errorListener); | |
| 389 } | 327 } |
| 390 | 328 |
| 391 void test_creation_nonEmpty() { | 329 void test_creation_nonEmpty() { |
| 392 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 330 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 393 String importedTypeName = "A"; | 331 String importedTypeName = "A"; |
| 394 ClassElement importedType = | 332 ClassElement importedType = |
| 395 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); | 333 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); |
| 396 LibraryElement importedLibrary = createTestLibrary(context, "imported"); | 334 LibraryElement importedLibrary = createTestLibrary(context, "imported"); |
| 397 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | 335 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) |
| 398 .types = <ClassElement>[importedType]; | 336 .types = <ClassElement>[importedType]; |
| 399 LibraryElementImpl definingLibrary = | 337 LibraryElementImpl definingLibrary = |
| 400 createTestLibrary(context, "importing"); | 338 createTestLibrary(context, "importing"); |
| 401 ImportElementImpl importElement = new ImportElementImpl(0); | 339 ImportElementImpl importElement = new ImportElementImpl(0); |
| 402 importElement.importedLibrary = importedLibrary; | 340 importElement.importedLibrary = importedLibrary; |
| 403 definingLibrary.imports = <ImportElement>[importElement]; | 341 definingLibrary.imports = <ImportElement>[importElement]; |
| 404 GatheringErrorListener errorListener = new GatheringErrorListener(); | 342 Scope scope = new LibraryImportScope(definingLibrary); |
| 405 Scope scope = new LibraryImportScope(definingLibrary, errorListener); | |
| 406 expect( | 343 expect( |
| 407 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), | 344 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), |
| 408 importedType); | 345 importedType); |
| 409 } | 346 } |
| 410 | 347 |
| 411 void test_getErrorListener() { | |
| 412 LibraryElement definingLibrary = createDefaultTestLibrary(); | |
| 413 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 414 LibraryImportScope scope = | |
| 415 new LibraryImportScope(definingLibrary, errorListener); | |
| 416 expect(scope.errorListener, errorListener); | |
| 417 } | |
| 418 | |
| 419 void test_nonConflictingImports_fromSdk() { | |
| 420 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | |
| 421 String typeName = "List"; | |
| 422 ClassElement type = ElementFactory.classElement2(typeName); | |
| 423 LibraryElement importedLibrary = createTestLibrary(context, "lib"); | |
| 424 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | |
| 425 .types = <ClassElement>[type]; | |
| 426 ImportElementImpl importCore = ElementFactory.importFor( | |
| 427 context.getLibraryElement(context.sourceFactory.forUri("dart:core")), | |
| 428 null); | |
| 429 ImportElementImpl importLib = | |
| 430 ElementFactory.importFor(importedLibrary, null); | |
| 431 LibraryElementImpl importingLibrary = | |
| 432 createTestLibrary(context, "importing"); | |
| 433 importingLibrary.imports = <ImportElement>[importCore, importLib]; | |
| 434 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 435 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | |
| 436 expect( | |
| 437 scope.lookup(AstFactory.identifier3(typeName), importingLibrary), type); | |
| 438 errorListener | |
| 439 .assertErrorsWithCodes([StaticWarningCode.CONFLICTING_DART_IMPORT]); | |
| 440 } | |
| 441 | |
| 442 void test_nonConflictingImports_sameElement() { | |
| 443 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | |
| 444 String typeNameA = "A"; | |
| 445 String typeNameB = "B"; | |
| 446 ClassElement typeA = ElementFactory.classElement2(typeNameA); | |
| 447 ClassElement typeB = ElementFactory.classElement2(typeNameB); | |
| 448 LibraryElement importedLibrary = createTestLibrary(context, "imported"); | |
| 449 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | |
| 450 .types = <ClassElement>[typeA, typeB]; | |
| 451 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null); | |
| 452 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null); | |
| 453 LibraryElementImpl importingLibrary = | |
| 454 createTestLibrary(context, "importing"); | |
| 455 importingLibrary.imports = <ImportElement>[import1, import2]; | |
| 456 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 457 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | |
| 458 expect(scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary), | |
| 459 typeA); | |
| 460 errorListener.assertNoErrors(); | |
| 461 expect(scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary), | |
| 462 typeB); | |
| 463 errorListener.assertNoErrors(); | |
| 464 } | |
| 465 | |
| 466 void test_prefixedAndNonPrefixed() { | 348 void test_prefixedAndNonPrefixed() { |
| 467 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 349 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 468 String typeName = "C"; | 350 String typeName = "C"; |
| 469 String prefixName = "p"; | 351 String prefixName = "p"; |
| 470 ClassElement prefixedType = ElementFactory.classElement2(typeName); | 352 ClassElement prefixedType = ElementFactory.classElement2(typeName); |
| 471 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName); | 353 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName); |
| 472 LibraryElement prefixedLibrary = | 354 LibraryElement prefixedLibrary = |
| 473 createTestLibrary(context, "import.prefixed"); | 355 createTestLibrary(context, "import.prefixed"); |
| 474 (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | 356 (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) |
| 475 .types = <ClassElement>[prefixedType]; | 357 .types = <ClassElement>[prefixedType]; |
| 476 ImportElementImpl prefixedImport = ElementFactory.importFor( | 358 ImportElementImpl prefixedImport = ElementFactory.importFor( |
| 477 prefixedLibrary, ElementFactory.prefix(prefixName)); | 359 prefixedLibrary, ElementFactory.prefix(prefixName)); |
| 478 LibraryElement nonPrefixedLibrary = | 360 LibraryElement nonPrefixedLibrary = |
| 479 createTestLibrary(context, "import.nonPrefixed"); | 361 createTestLibrary(context, "import.nonPrefixed"); |
| 480 (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | 362 (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) |
| 481 .types = <ClassElement>[nonPrefixedType]; | 363 .types = <ClassElement>[nonPrefixedType]; |
| 482 ImportElementImpl nonPrefixedImport = | 364 ImportElementImpl nonPrefixedImport = |
| 483 ElementFactory.importFor(nonPrefixedLibrary, null); | 365 ElementFactory.importFor(nonPrefixedLibrary, null); |
| 484 LibraryElementImpl importingLibrary = | 366 LibraryElementImpl importingLibrary = |
| 485 createTestLibrary(context, "importing"); | 367 createTestLibrary(context, "importing"); |
| 486 importingLibrary.imports = <ImportElement>[ | 368 importingLibrary.imports = <ImportElement>[ |
| 487 prefixedImport, | 369 prefixedImport, |
| 488 nonPrefixedImport | 370 nonPrefixedImport |
| 489 ]; | 371 ]; |
| 490 GatheringErrorListener errorListener = new GatheringErrorListener(); | 372 Scope scope = new LibraryImportScope(importingLibrary); |
| 491 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | |
| 492 Element prefixedElement = scope.lookup( | 373 Element prefixedElement = scope.lookup( |
| 493 AstFactory.identifier5(prefixName, typeName), importingLibrary); | 374 AstFactory.identifier5(prefixName, typeName), importingLibrary); |
| 494 errorListener.assertNoErrors(); | |
| 495 expect(prefixedElement, same(prefixedType)); | 375 expect(prefixedElement, same(prefixedType)); |
| 496 Element nonPrefixedElement = | 376 Element nonPrefixedElement = |
| 497 scope.lookup(AstFactory.identifier3(typeName), importingLibrary); | 377 scope.lookup(AstFactory.identifier3(typeName), importingLibrary); |
| 498 errorListener.assertNoErrors(); | |
| 499 expect(nonPrefixedElement, same(nonPrefixedType)); | 378 expect(nonPrefixedElement, same(nonPrefixedType)); |
| 500 } | 379 } |
| 501 } | 380 } |
| 502 | 381 |
| 503 @reflectiveTest | 382 @reflectiveTest |
| 504 class LibraryScopeTest extends ResolverTestCase { | 383 class LibraryScopeTest extends ResolverTestCase { |
| 505 void test_creation_empty() { | 384 void test_creation_empty() { |
| 506 LibraryElement definingLibrary = createDefaultTestLibrary(); | 385 new LibraryScope(createDefaultTestLibrary()); |
| 507 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 508 new LibraryScope(definingLibrary, errorListener); | |
| 509 } | 386 } |
| 510 | 387 |
| 511 void test_creation_nonEmpty() { | 388 void test_creation_nonEmpty() { |
| 512 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 389 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 513 String importedTypeName = "A"; | 390 String importedTypeName = "A"; |
| 514 ClassElement importedType = | 391 ClassElement importedType = |
| 515 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); | 392 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); |
| 516 LibraryElement importedLibrary = createTestLibrary(context, "imported"); | 393 LibraryElement importedLibrary = createTestLibrary(context, "imported"); |
| 517 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) | 394 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) |
| 518 .types = <ClassElement>[importedType]; | 395 .types = <ClassElement>[importedType]; |
| 519 LibraryElementImpl definingLibrary = | 396 LibraryElementImpl definingLibrary = |
| 520 createTestLibrary(context, "importing"); | 397 createTestLibrary(context, "importing"); |
| 521 ImportElementImpl importElement = new ImportElementImpl(0); | 398 ImportElementImpl importElement = new ImportElementImpl(0); |
| 522 importElement.importedLibrary = importedLibrary; | 399 importElement.importedLibrary = importedLibrary; |
| 523 definingLibrary.imports = <ImportElement>[importElement]; | 400 definingLibrary.imports = <ImportElement>[importElement]; |
| 524 GatheringErrorListener errorListener = new GatheringErrorListener(); | 401 Scope scope = new LibraryScope(definingLibrary); |
| 525 Scope scope = new LibraryScope(definingLibrary, errorListener); | |
| 526 expect( | 402 expect( |
| 527 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), | 403 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), |
| 528 importedType); | 404 importedType); |
| 529 } | 405 } |
| 530 | |
| 531 void test_getErrorListener() { | |
| 532 LibraryElement definingLibrary = createDefaultTestLibrary(); | |
| 533 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 534 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); | |
| 535 expect(scope.errorListener, errorListener); | |
| 536 } | |
| 537 } | 406 } |
| 538 | 407 |
| 539 @reflectiveTest | 408 @reflectiveTest |
| 540 class PrefixedNamespaceTest extends ResolverTestCase { | 409 class PrefixedNamespaceTest extends ResolverTestCase { |
| 541 void test_lookup_missing() { | 410 void test_lookup_missing() { |
| 542 ClassElement element = ElementFactory.classElement2('A'); | 411 ClassElement element = ElementFactory.classElement2('A'); |
| 543 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element])); | 412 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element])); |
| 544 expect(namespace.get('p.B'), isNull); | 413 expect(namespace.get('p.B'), isNull); |
| 545 } | 414 } |
| 546 | 415 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 458 |
| 590 @override | 459 @override |
| 591 Element internalLookup(Identifier identifier, String name, | 460 Element internalLookup(Identifier identifier, String name, |
| 592 LibraryElement referencingLibrary) => | 461 LibraryElement referencingLibrary) => |
| 593 null; | 462 null; |
| 594 } | 463 } |
| 595 | 464 |
| 596 @reflectiveTest | 465 @reflectiveTest |
| 597 class ScopeTest extends ResolverTestCase { | 466 class ScopeTest extends ResolverTestCase { |
| 598 void test_define_duplicate() { | 467 void test_define_duplicate() { |
| 599 GatheringErrorListener errorListener = new GatheringErrorListener(); | 468 ScopeTest_TestScope scope = new ScopeTest_TestScope(); |
| 600 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | |
| 601 SimpleIdentifier identifier = AstFactory.identifier3("v1"); | 469 SimpleIdentifier identifier = AstFactory.identifier3("v1"); |
| 602 VariableElement element1 = ElementFactory.localVariableElement(identifier); | 470 VariableElement element1 = ElementFactory.localVariableElement(identifier); |
| 603 VariableElement element2 = ElementFactory.localVariableElement(identifier); | 471 VariableElement element2 = ElementFactory.localVariableElement(identifier); |
| 604 scope.define(element1); | 472 scope.define(element1); |
| 605 scope.define(element2); | 473 scope.define(element2); |
| 606 expect(scope.lookup(identifier, null), element1); | 474 expect(scope.lookup(identifier, null), element1); |
| 607 } | 475 } |
| 608 | 476 |
| 609 void test_define_normal() { | 477 void test_define_normal() { |
| 610 GatheringErrorListener errorListener = new GatheringErrorListener(); | 478 ScopeTest_TestScope scope = new ScopeTest_TestScope(); |
| 611 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | |
| 612 VariableElement element1 = | 479 VariableElement element1 = |
| 613 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); | 480 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); |
| 614 VariableElement element2 = | 481 VariableElement element2 = |
| 615 ElementFactory.localVariableElement(AstFactory.identifier3("v2")); | 482 ElementFactory.localVariableElement(AstFactory.identifier3("v2")); |
| 616 scope.define(element1); | 483 scope.define(element1); |
| 617 scope.define(element2); | 484 scope.define(element2); |
| 618 errorListener.assertNoErrors(); | |
| 619 } | |
| 620 | |
| 621 void test_getErrorListener() { | |
| 622 GatheringErrorListener errorListener = new GatheringErrorListener(); | |
| 623 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | |
| 624 expect(scope.errorListener, errorListener); | |
| 625 } | 485 } |
| 626 | 486 |
| 627 void test_isPrivateName_nonPrivate() { | 487 void test_isPrivateName_nonPrivate() { |
| 628 expect(Scope.isPrivateName("Public"), isFalse); | 488 expect(Scope.isPrivateName("Public"), isFalse); |
| 629 } | 489 } |
| 630 | 490 |
| 631 void test_isPrivateName_private() { | 491 void test_isPrivateName_private() { |
| 632 expect(Scope.isPrivateName("_Private"), isTrue); | 492 expect(Scope.isPrivateName("_Private"), isTrue); |
| 633 } | 493 } |
| 634 } | 494 } |
| 635 | 495 |
| 636 /** | 496 /** |
| 637 * A non-abstract subclass that can be used for testing purposes. | 497 * A non-abstract subclass that can be used for testing purposes. |
| 638 */ | 498 */ |
| 639 class ScopeTest_TestScope extends Scope { | 499 class ScopeTest_TestScope extends Scope { |
| 640 /** | 500 ScopeTest_TestScope(); |
| 641 * The listener that is to be informed when an error is encountered. | |
| 642 */ | |
| 643 final AnalysisErrorListener errorListener; | |
| 644 | 501 |
| 645 ScopeTest_TestScope(this.errorListener); | 502 @deprecated |
| 503 @override |
| 504 AnalysisErrorListener get errorListener => null; |
| 646 | 505 |
| 647 @override | 506 @override |
| 648 Element internalLookup(Identifier identifier, String name, | 507 Element internalLookup(Identifier identifier, String name, |
| 649 LibraryElement referencingLibrary) => | 508 LibraryElement referencingLibrary) => |
| 650 localLookup(name, referencingLibrary); | 509 localLookup(name, referencingLibrary); |
| 651 } | 510 } |
| 652 | 511 |
| 653 class SourceContainer_ChangeSetTest_test_toString implements SourceContainer { | 512 class SourceContainer_ChangeSetTest_test_toString implements SourceContainer { |
| 654 @override | 513 @override |
| 655 bool contains(Source source) => false; | 514 bool contains(Source source) => false; |
| (...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); | 2781 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); |
| 2923 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore( | 2782 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore( |
| 2924 resourceProvider: resourceProvider); | 2783 resourceProvider: resourceProvider); |
| 2925 Source librarySource = | 2784 Source librarySource = |
| 2926 new FileSource(resourceProvider.getFile("/lib.dart")); | 2785 new FileSource(resourceProvider.getFile("/lib.dart")); |
| 2927 LibraryElementImpl element = new LibraryElementImpl.forNode( | 2786 LibraryElementImpl element = new LibraryElementImpl.forNode( |
| 2928 context, AstFactory.libraryIdentifier2(["lib"])); | 2787 context, AstFactory.libraryIdentifier2(["lib"])); |
| 2929 element.definingCompilationUnit = | 2788 element.definingCompilationUnit = |
| 2930 new CompilationUnitElementImpl("lib.dart"); | 2789 new CompilationUnitElementImpl("lib.dart"); |
| 2931 _typeProvider = new TestTypeProvider(); | 2790 _typeProvider = new TestTypeProvider(); |
| 2932 libraryScope = new LibraryScope(element, _listener); | 2791 libraryScope = new LibraryScope(element); |
| 2933 _visitor = new TypeResolverVisitor( | 2792 _visitor = new TypeResolverVisitor( |
| 2934 element, librarySource, _typeProvider, _listener, | 2793 element, librarySource, _typeProvider, _listener, |
| 2935 nameScope: libraryScope); | 2794 nameScope: libraryScope); |
| 2936 } | 2795 } |
| 2937 | 2796 |
| 2938 void test_visitCatchClause_exception() { | 2797 void test_visitCatchClause_exception() { |
| 2939 // catch (e) | 2798 // catch (e) |
| 2940 CatchClause clause = AstFactory.catchClause("e"); | 2799 CatchClause clause = AstFactory.catchClause("e"); |
| 2941 SimpleIdentifier exceptionParameter = clause.exceptionParameter; | 2800 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
| 2942 exceptionParameter.staticElement = | 2801 exceptionParameter.staticElement = |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 */ | 3389 */ |
| 3531 class _StaleElement extends ElementImpl { | 3390 class _StaleElement extends ElementImpl { |
| 3532 _StaleElement() : super("_StaleElement", -1); | 3391 _StaleElement() : super("_StaleElement", -1); |
| 3533 | 3392 |
| 3534 @override | 3393 @override |
| 3535 get kind => throw "_StaleElement's kind shouldn't be accessed"; | 3394 get kind => throw "_StaleElement's kind shouldn't be accessed"; |
| 3536 | 3395 |
| 3537 @override | 3396 @override |
| 3538 accept(_) => throw "_StaleElement shouldn't be visited"; | 3397 accept(_) => throw "_StaleElement shouldn't be visited"; |
| 3539 } | 3398 } |
| OLD | NEW |