Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: pkg/analyzer/test/src/dart/element/element_test.dart

Issue 2967203002: Remove CompilationUnitElement.getElementAt(). (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/fasta/mock_element.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/element/element_test.dart
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 0cff4a6c3e87f98429bfc190eed7094950e6b9cd..2eef5fdeb509d13572eeda0e9d19c09e0152f8b0 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -964,96 +964,6 @@ abstract class A<K, V> = Object with MapMixin<K, V>;
@reflectiveTest
class CompilationUnitElementImplTest extends EngineTestCase {
- void test_getElementAt() {
- AnalysisContextHelper contextHelper = new AnalysisContextHelper();
- AnalysisContext context = contextHelper.context;
- String code = r'''
-class A {
- int field;
-}
-main() {
- int localVar = 42;
-}
-''';
- Source libSource = contextHelper.addSource("/my_lib.dart", code);
- // prepare library/unit elements
- LibraryElement libraryElement = context.computeLibraryElement(libSource);
- CompilationUnitElement unitElement = libraryElement.definingCompilationUnit;
- // A
- ClassElement elementA;
- {
- int offset = code.indexOf('A {');
- elementA = unitElement.getElementAt(offset);
- expect(elementA, isNotNull);
- expect(elementA.enclosingElement, unitElement);
- expect(elementA.name, 'A');
- }
- // A.field
- {
- int offset = code.indexOf('field;');
- FieldElement element = unitElement.getElementAt(offset);
- expect(element, isNotNull);
- expect(element.enclosingElement, elementA);
- expect(element.name, 'field');
- }
- // main
- FunctionElement mainElement;
- {
- int offset = code.indexOf('main() {');
- mainElement = unitElement.getElementAt(offset);
- expect(mainElement, isNotNull);
- expect(mainElement.enclosingElement, unitElement);
- expect(mainElement.name, 'main');
- }
- // main.localVar
- {
- int offset = code.indexOf('localVar');
- LocalVariableElement element = unitElement.getElementAt(offset);
- expect(element, isNotNull);
- expect(element.enclosingElement, mainElement);
- expect(element.name, 'localVar');
- }
- // null
- expect(unitElement.getElementAt(1000), isNull);
- }
-
- void test_getElementAt_multipleUnitsInLibrary() {
- AnalysisContextHelper contextHelper = new AnalysisContextHelper();
- AnalysisContext context = contextHelper.context;
- Source libSource = contextHelper.addSource(
- "/my_lib.dart",
- r'''
-library my_lib;
-part 'unit_a.dart';
-part 'unit_b.dart';
-''');
- Source unitSourceA =
- contextHelper.addSource("/unit_a.dart", 'part of my_lib;class A {}');
- Source unitSourceB =
- contextHelper.addSource("/unit_b.dart", 'part of my_lib;class B {}');
- int offset = 'part of my_lib;class A {}'.indexOf('A {}');
- // prepare library/unit elements
- context.computeLibraryElement(libSource);
- CompilationUnitElement unitElementA =
- context.getCompilationUnitElement(unitSourceA, libSource);
- CompilationUnitElement unitElementB =
- context.getCompilationUnitElement(unitSourceB, libSource);
- // A
- {
- ClassElement element = unitElementA.getElementAt(offset);
- expect(element, isNotNull);
- expect(element.enclosingElement, unitElementA);
- expect(element.name, 'A');
- }
- // B
- {
- ClassElement element = unitElementB.getElementAt(offset);
- expect(element, isNotNull);
- expect(element.enclosingElement, unitElementB);
- expect(element.name, 'B');
- }
- }
-
void test_getEnum_declared() {
TestTypeProvider typeProvider = new TestTypeProvider();
CompilationUnitElementImpl unit =
« no previous file with comments | « pkg/analyzer/lib/src/fasta/mock_element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698