| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_case; | 5 library analyzer.test.generated.resolver_test_case; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| 11 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
| 12 import 'package:analyzer/file_system/memory_file_system.dart'; | 12 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 13 import 'package:analyzer/src/dart/element/element.dart'; | 13 import 'package:analyzer/src/dart/element/element.dart'; |
| 14 import 'package:analyzer/src/dart/element/type.dart'; | 14 import 'package:analyzer/src/dart/element/type.dart'; |
| 15 import 'package:analyzer/src/error/codes.dart'; | 15 import 'package:analyzer/src/error/codes.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/java_engine.dart'; | 17 import 'package:analyzer/src/generated/java_engine.dart'; |
| 18 import 'package:analyzer/src/generated/resolver.dart'; | 18 import 'package:analyzer/src/generated/resolver.dart'; |
| 19 import 'package:analyzer/src/generated/source_io.dart'; | 19 import 'package:analyzer/src/generated/source_io.dart'; |
| 20 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 20 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
| 21 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 21 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 22 import 'package:test/test.dart'; | 22 import 'package:test/test.dart'; |
| 23 | 23 |
| 24 import 'analysis_context_factory.dart'; | 24 import 'analysis_context_factory.dart'; |
| 25 import 'test_support.dart'; | 25 import 'test_support.dart'; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * An AST visitor used to verify that all of the nodes in an AST structure that | 28 * An AST visitor used to verify that all of the nodes in an AST structure that |
| 29 * should have been resolved were resolved. | 29 * should have been resolved were resolved. |
| 30 */ | 30 */ |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 Source definingCompilationUnitSource = createNamedSource(fileName); | 537 Source definingCompilationUnitSource = createNamedSource(fileName); |
| 538 List<CompilationUnitElement> sourcedCompilationUnits; | 538 List<CompilationUnitElement> sourcedCompilationUnits; |
| 539 if (typeNames == null) { | 539 if (typeNames == null) { |
| 540 sourcedCompilationUnits = CompilationUnitElement.EMPTY_LIST; | 540 sourcedCompilationUnits = CompilationUnitElement.EMPTY_LIST; |
| 541 } else { | 541 } else { |
| 542 int count = typeNames.length; | 542 int count = typeNames.length; |
| 543 sourcedCompilationUnits = new List<CompilationUnitElement>(count); | 543 sourcedCompilationUnits = new List<CompilationUnitElement>(count); |
| 544 for (int i = 0; i < count; i++) { | 544 for (int i = 0; i < count; i++) { |
| 545 String typeName = typeNames[i]; | 545 String typeName = typeNames[i]; |
| 546 ClassElementImpl type = | 546 ClassElementImpl type = |
| 547 new ClassElementImpl.forNode(AstFactory.identifier3(typeName)); | 547 new ClassElementImpl.forNode(AstTestFactory.identifier3(typeName)); |
| 548 String fileName = "$typeName.dart"; | 548 String fileName = "$typeName.dart"; |
| 549 CompilationUnitElementImpl compilationUnit = | 549 CompilationUnitElementImpl compilationUnit = |
| 550 new CompilationUnitElementImpl(fileName); | 550 new CompilationUnitElementImpl(fileName); |
| 551 compilationUnit.source = createNamedSource(fileName); | 551 compilationUnit.source = createNamedSource(fileName); |
| 552 compilationUnit.librarySource = definingCompilationUnitSource; | 552 compilationUnit.librarySource = definingCompilationUnitSource; |
| 553 compilationUnit.types = <ClassElement>[type]; | 553 compilationUnit.types = <ClassElement>[type]; |
| 554 sourcedCompilationUnits[i] = compilationUnit; | 554 sourcedCompilationUnits[i] = compilationUnit; |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 CompilationUnitElementImpl compilationUnit = | 557 CompilationUnitElementImpl compilationUnit = |
| 558 new CompilationUnitElementImpl(fileName); | 558 new CompilationUnitElementImpl(fileName); |
| 559 compilationUnit.librarySource = | 559 compilationUnit.librarySource = |
| 560 compilationUnit.source = definingCompilationUnitSource; | 560 compilationUnit.source = definingCompilationUnitSource; |
| 561 LibraryElementImpl library = new LibraryElementImpl.forNode( | 561 LibraryElementImpl library = new LibraryElementImpl.forNode( |
| 562 context, AstFactory.libraryIdentifier2([libraryName])); | 562 context, AstTestFactory.libraryIdentifier2([libraryName])); |
| 563 library.definingCompilationUnit = compilationUnit; | 563 library.definingCompilationUnit = compilationUnit; |
| 564 library.parts = sourcedCompilationUnits; | 564 library.parts = sourcedCompilationUnits; |
| 565 return library; | 565 return library; |
| 566 } | 566 } |
| 567 | 567 |
| 568 /** | 568 /** |
| 569 * Return the `SimpleIdentifier` marked by `marker`. The source code must have
no | 569 * Return the `SimpleIdentifier` marked by `marker`. The source code must have
no |
| 570 * errors and be verifiable. | 570 * errors and be verifiable. |
| 571 * | 571 * |
| 572 * @param code source code to analyze. | 572 * @param code source code to analyze. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. | 835 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. |
| 836 */ | 836 */ |
| 837 _expectType(DartType type, expected) { | 837 _expectType(DartType type, expected) { |
| 838 if (expected is String) { | 838 if (expected is String) { |
| 839 expect(type.toString(), expected); | 839 expect(type.toString(), expected); |
| 840 } else { | 840 } else { |
| 841 expect(type, expected); | 841 expect(type, expected); |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 } | 844 } |
| OLD | NEW |