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 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
11 import 'package:analysis_server/src/services/index2/index2.dart'; | 11 import 'package:analysis_server/src/services/index/index.dart'; |
12 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 12 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
13 import 'package:analysis_server/src/services/search/search_engine_internal2.dart
'; | 13 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
14 import 'package:analyzer/dart/ast/ast.dart'; | 14 import 'package:analyzer/dart/ast/ast.dart'; |
15 import 'package:analyzer/file_system/file_system.dart'; | 15 import 'package:analyzer/file_system/file_system.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:unittest/unittest.dart'; | 17 import 'package:unittest/unittest.dart'; |
18 | 18 |
19 import '../../abstract_single_unit.dart'; | 19 import '../../abstract_single_unit.dart'; |
20 | 20 |
21 int findIdentifierLength(String search) { | 21 int findIdentifierLength(String search) { |
22 int length = 0; | 22 int length = 0; |
23 while (length < search.length) { | 23 while (length < search.length) { |
24 int c = search.codeUnitAt(length); | 24 int c = search.codeUnitAt(length); |
25 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || | 25 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || |
26 c >= 'A'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0) || | 26 c >= 'A'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0) || |
27 c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0))) { | 27 c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0))) { |
28 break; | 28 break; |
29 } | 29 } |
30 length++; | 30 length++; |
31 } | 31 } |
32 return length; | 32 return length; |
33 } | 33 } |
34 | 34 |
35 /** | 35 /** |
36 * The base class for all [Refactoring] tests. | 36 * The base class for all [Refactoring] tests. |
37 */ | 37 */ |
38 abstract class RefactoringTest extends AbstractSingleUnitTest { | 38 abstract class RefactoringTest extends AbstractSingleUnitTest { |
39 Index2 index; | 39 Index index; |
40 SearchEngineImpl2 searchEngine; | 40 SearchEngineImpl searchEngine; |
41 | 41 |
42 SourceChange refactoringChange; | 42 SourceChange refactoringChange; |
43 | 43 |
44 Refactoring get refactoring; | 44 Refactoring get refactoring; |
45 | 45 |
46 /** | 46 /** |
47 * Asserts that [refactoringChange] contains a [FileEdit] for the file | 47 * Asserts that [refactoringChange] contains a [FileEdit] for the file |
48 * with the given [path], and it results the [expectedCode]. | 48 * with the given [path], and it results the [expectedCode]. |
49 */ | 49 */ |
50 void assertFileChangeResult(String path, String expectedCode) { | 50 void assertFileChangeResult(String path, String expectedCode) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 void indexUnit(String file, String code) { | 153 void indexUnit(String file, String code) { |
154 Source source = addSource(file, code); | 154 Source source = addSource(file, code); |
155 CompilationUnit unit = resolveLibraryUnit(source); | 155 CompilationUnit unit = resolveLibraryUnit(source); |
156 index.indexUnit(unit); | 156 index.indexUnit(unit); |
157 } | 157 } |
158 | 158 |
159 void setUp() { | 159 void setUp() { |
160 super.setUp(); | 160 super.setUp(); |
161 index = createMemoryIndex2(); | 161 index = createMemoryIndex(); |
162 searchEngine = new SearchEngineImpl2(index); | 162 searchEngine = new SearchEngineImpl(index); |
163 } | 163 } |
164 } | 164 } |
OLD | NEW |