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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/src/services/correction/status.dart'; | 7 import 'package:analysis_server/src/services/correction/status.dart'; |
8 import 'package:analysis_server/src/services/index/index.dart'; | 8 import 'package:analysis_server/src/services/index/index.dart'; |
9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
10 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
11 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | |
12 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; | 11 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; |
13 import 'package:analyzer/dart/ast/ast.dart'; | 12 import 'package:analyzer/dart/ast/ast.dart'; |
14 import 'package:analyzer/dart/element/element.dart' show Element; | 13 import 'package:analyzer/dart/element/element.dart' show Element; |
15 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
16 import 'package:analyzer/src/dart/analysis/ast_provider_context.dart'; | |
17 import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart'; | 15 import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart'; |
18 import 'package:analyzer/src/dart/element/ast_provider.dart'; | 16 import 'package:analyzer/src/dart/element/ast_provider.dart'; |
19 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
20 import 'package:analyzer_plugin/protocol/protocol_common.dart' | 18 import 'package:analyzer_plugin/protocol/protocol_common.dart' |
21 show | 19 show |
22 RefactoringProblem, | 20 RefactoringProblem, |
23 RefactoringProblemSeverity, | 21 RefactoringProblemSeverity, |
24 SourceChange, | 22 SourceChange, |
25 SourceEdit, | 23 SourceEdit, |
26 SourceFileEdit; | 24 SourceFileEdit; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 /** | 156 /** |
159 * Completes with a fully resolved unit that contains the [element]. | 157 * Completes with a fully resolved unit that contains the [element]. |
160 */ | 158 */ |
161 Future<CompilationUnit> getResolvedUnitWithElement(Element element) async { | 159 Future<CompilationUnit> getResolvedUnitWithElement(Element element) async { |
162 return element.context | 160 return element.context |
163 .resolveCompilationUnit(element.source, element.library); | 161 .resolveCompilationUnit(element.source, element.library); |
164 } | 162 } |
165 | 163 |
166 Future<Null> indexTestUnit(String code) async { | 164 Future<Null> indexTestUnit(String code) async { |
167 await resolveTestUnit(code); | 165 await resolveTestUnit(code); |
168 if (!enableNewAnalysisDriver) { | |
169 index.indexUnit(testUnit); | |
170 } | |
171 } | 166 } |
172 | 167 |
173 Future<Null> indexUnit(String file, String code) async { | 168 Future<Null> indexUnit(String file, String code) async { |
174 Source source = addSource(file, code); | 169 addSource(file, code); |
175 if (!enableNewAnalysisDriver) { | |
176 CompilationUnit unit = await resolveLibraryUnit(source); | |
177 index.indexUnit(unit); | |
178 } | |
179 } | 170 } |
180 | 171 |
181 void setUp() { | 172 void setUp() { |
182 super.setUp(); | 173 super.setUp(); |
183 if (enableNewAnalysisDriver) { | 174 searchEngine = new SearchEngineImpl2([driver]); |
184 searchEngine = new SearchEngineImpl2([driver]); | 175 astProvider = new AstProviderForDriver(driver); |
185 astProvider = new AstProviderForDriver(driver); | |
186 } else { | |
187 index = createMemoryIndex(); | |
188 searchEngine = new SearchEngineImpl( | |
189 index, (_) => new AstProviderForContext(context)); | |
190 astProvider = new AstProviderForContext(context); | |
191 } | |
192 } | 176 } |
193 } | 177 } |
OLD | NEW |