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

Side by Side Diff: pkg/analyzer/test/src/abstract_single_unit.dart

Issue 1735243003: Initial package indexing implementation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 test.services.src.index.abstract_single_file; 5 library test.services.src.index.abstract_single_file;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/java_engine.dart'; 10 import 'package:analyzer/src/generated/java_engine.dart';
11 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
12 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
13 13
14 import 'abstract_context.dart'; 14 import 'context/abstract_context.dart';
15 15
16 class AbstractSingleUnitTest extends AbstractContextTest { 16 class AbstractSingleUnitTest extends AbstractContextTest {
17 bool verifyNoTestUnitErrors = true; 17 bool verifyNoTestUnitErrors = true;
18 18
19 String testCode; 19 String testCode;
20 String testFile = '/test.dart'; 20 String testFile = '/test.dart';
21 Source testSource; 21 Source testSource;
22 CompilationUnit testUnit; 22 CompilationUnit testUnit;
23 CompilationUnitElement testUnitElement; 23 CompilationUnitElement testUnitElement;
24 LibraryElement testLibraryElement; 24 LibraryElement testLibraryElement;
25 25
26 void addTestSource(String code, [Uri uri]) { 26 void addTestSource(String code, [Uri uri]) {
27 testCode = code; 27 testCode = code;
28 testSource = addSource(testFile, code, uri); 28 testSource = addSource(testFile, code);
29 } 29 }
30 30
31 void assertNoErrorsInSource(Source source) { 31 void assertNoErrorsInSource(Source source) {
32 List<AnalysisError> errors = context.getErrors(source).errors; 32 List<AnalysisError> errors = context.getErrors(source).errors;
33 expect(errors, isEmpty); 33 expect(errors, isEmpty);
34 } 34 }
35 35
36 Element findElement(String name, [ElementKind kind]) { 36 Element findElement(String name, [ElementKind kind]) {
37 return findChildElement(testUnitElement, name, kind); 37 return findChildElement(testUnitElement, name, kind);
38 } 38 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void resolveTestUnit(String code) { 100 void resolveTestUnit(String code) {
101 addTestSource(code); 101 addTestSource(code);
102 testUnit = resolveLibraryUnit(testSource); 102 testUnit = resolveLibraryUnit(testSource);
103 if (verifyNoTestUnitErrors) { 103 if (verifyNoTestUnitErrors) {
104 assertNoErrorsInSource(testSource); 104 assertNoErrorsInSource(testSource);
105 } 105 }
106 testUnitElement = testUnit.element; 106 testUnitElement = testUnit.element;
107 testLibraryElement = testUnitElement.library; 107 testLibraryElement = testUnitElement.library;
108 } 108 }
109 } 109 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | pkg/analyzer/test/src/context/abstract_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698