| 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 test.services.refactoring; | 5 library test.services.refactoring; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 show | 10 show |
| 11 RefactoringProblem, | 11 RefactoringProblem, |
| 12 RefactoringProblemSeverity, | 12 RefactoringProblemSeverity, |
| 13 SourceChange, | 13 SourceChange, |
| 14 SourceEdit, | 14 SourceEdit, |
| 15 SourceFileEdit; | 15 SourceFileEdit; |
| 16 import 'package:analysis_server/src/services/correction/status.dart'; | 16 import 'package:analysis_server/src/services/correction/status.dart'; |
| 17 import 'package:analysis_server/src/services/index/index.dart'; | 17 import 'package:analysis_server/src/services/index/index.dart'; |
| 18 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 18 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| 19 import 'package:analysis_server/src/services/search/search_engine.dart'; | 19 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 21 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; | 21 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; |
| 22 import 'package:analyzer/dart/ast/ast.dart'; | 22 import 'package:analyzer/dart/ast/ast.dart'; |
| 23 import 'package:analyzer/dart/element/element.dart' show Element; | 23 import 'package:analyzer/dart/element/element.dart' show Element; |
| 24 import 'package:analyzer/file_system/file_system.dart'; | 24 import 'package:analyzer/file_system/file_system.dart'; |
| 25 import 'package:analyzer/src/dart/analysis/ast_provider_context.dart'; |
| 26 import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart'; |
| 27 import 'package:analyzer/src/dart/element/ast_provider.dart'; |
| 25 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
| 26 import 'package:test/test.dart'; | 29 import 'package:test/test.dart'; |
| 27 | 30 |
| 28 import '../../abstract_single_unit.dart'; | 31 import '../../abstract_single_unit.dart'; |
| 29 | 32 |
| 30 int findIdentifierLength(String search) { | 33 int findIdentifierLength(String search) { |
| 31 int length = 0; | 34 int length = 0; |
| 32 while (length < search.length) { | 35 while (length < search.length) { |
| 33 int c = search.codeUnitAt(length); | 36 int c = search.codeUnitAt(length); |
| 34 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || | 37 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || |
| 35 c >= 'A'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0) || | 38 c >= 'A'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0) || |
| 36 c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0))) { | 39 c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0))) { |
| 37 break; | 40 break; |
| 38 } | 41 } |
| 39 length++; | 42 length++; |
| 40 } | 43 } |
| 41 return length; | 44 return length; |
| 42 } | 45 } |
| 43 | 46 |
| 44 /** | 47 /** |
| 45 * The base class for all [Refactoring] tests. | 48 * The base class for all [Refactoring] tests. |
| 46 */ | 49 */ |
| 47 abstract class RefactoringTest extends AbstractSingleUnitTest { | 50 abstract class RefactoringTest extends AbstractSingleUnitTest { |
| 48 Index index; | 51 Index index; |
| 49 SearchEngine searchEngine; | 52 SearchEngine searchEngine; |
| 53 AstProvider astProvider; |
| 50 | 54 |
| 51 SourceChange refactoringChange; | 55 SourceChange refactoringChange; |
| 52 | 56 |
| 53 Refactoring get refactoring; | 57 Refactoring get refactoring; |
| 54 | 58 |
| 55 /** | 59 /** |
| 56 * Asserts that [refactoringChange] contains a [FileEdit] for the file | 60 * Asserts that [refactoringChange] contains a [FileEdit] for the file |
| 57 * with the given [path], and it results the [expectedCode]. | 61 * with the given [path], and it results the [expectedCode]. |
| 58 */ | 62 */ |
| 59 void assertFileChangeResult(String path, String expectedCode) { | 63 void assertFileChangeResult(String path, String expectedCode) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (!enableNewAnalysisDriver) { | 177 if (!enableNewAnalysisDriver) { |
| 174 CompilationUnit unit = await resolveLibraryUnit(source); | 178 CompilationUnit unit = await resolveLibraryUnit(source); |
| 175 index.indexUnit(unit); | 179 index.indexUnit(unit); |
| 176 } | 180 } |
| 177 } | 181 } |
| 178 | 182 |
| 179 void setUp() { | 183 void setUp() { |
| 180 super.setUp(); | 184 super.setUp(); |
| 181 if (enableNewAnalysisDriver) { | 185 if (enableNewAnalysisDriver) { |
| 182 searchEngine = new SearchEngineImpl2([driver]); | 186 searchEngine = new SearchEngineImpl2([driver]); |
| 187 astProvider = new AstProviderForDriver(driver); |
| 183 } else { | 188 } else { |
| 184 index = createMemoryIndex(); | 189 index = createMemoryIndex(); |
| 185 searchEngine = new SearchEngineImpl(index); | 190 searchEngine = new SearchEngineImpl(index); |
| 191 astProvider = new AstProviderForContext(context); |
| 186 } | 192 } |
| 187 } | 193 } |
| 188 } | 194 } |
| OLD | NEW |