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.domain.analysis.abstract; | 5 library test.domain.analysis.abstract; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
11 import 'package:analysis_server/src/domain_analysis.dart'; | 11 import 'package:analysis_server/src/domain_analysis.dart'; |
12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
13 import 'package:analysis_services/constants.dart'; | 13 import 'package:analysis_services/constants.dart'; |
14 import 'package:analysis_services/index/index.dart'; | 14 import 'package:analysis_services/index/index.dart'; |
15 import 'package:analysis_testing/mock_sdk.dart'; | 15 import 'package:analysis_testing/mock_sdk.dart'; |
16 import 'package:analyzer/file_system/file_system.dart'; | 16 import 'package:analyzer/file_system/file_system.dart'; |
17 import 'package:analyzer/file_system/memory_file_system.dart'; | 17 import 'package:analyzer/file_system/memory_file_system.dart'; |
18 import 'package:analyzer/src/generated/source.dart'; | |
19 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
20 | 19 |
21 import 'mocks.dart'; | 20 import 'mocks.dart'; |
22 | 21 |
23 | 22 |
24 int findIdentifierLength(String search) { | 23 int findIdentifierLength(String search) { |
25 int length = 0; | 24 int length = 0; |
26 while (length < search.length) { | 25 while (length < search.length) { |
27 int c = search.codeUnitAt(length); | 26 int c = search.codeUnitAt(length); |
28 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || | 27 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 request.setParameter(EXCLUDED, []); | 99 request.setParameter(EXCLUDED, []); |
101 handleSuccessfulRequest(request); | 100 handleSuccessfulRequest(request); |
102 } | 101 } |
103 | 102 |
104 /** | 103 /** |
105 * Returns the offset of [search] in [testCode]. | 104 * Returns the offset of [search] in [testCode]. |
106 * Fails if not found. | 105 * Fails if not found. |
107 */ | 106 */ |
108 int findFileOffset(String path, String search) { | 107 int findFileOffset(String path, String search) { |
109 File file = resourceProvider.getResource(path) as File; | 108 File file = resourceProvider.getResource(path) as File; |
110 String code = file.createSource(UriKind.FILE_URI).contents.data; | 109 String code = file.createSource().contents.data; |
111 int offset = code.indexOf(search); | 110 int offset = code.indexOf(search); |
112 expect(offset, isNot(-1), reason: '"$search" in\n$code'); | 111 expect(offset, isNot(-1), reason: '"$search" in\n$code'); |
113 return offset; | 112 return offset; |
114 } | 113 } |
115 | 114 |
116 /** | 115 /** |
117 * Returns the offset of [search] in [testCode]. | 116 * Returns the offset of [search] in [testCode]. |
118 * Fails if not found. | 117 * Fails if not found. |
119 */ | 118 */ |
120 int findOffset(String search) { | 119 int findOffset(String search) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return waitForServerOperationsPerformed(server); | 253 return waitForServerOperationsPerformed(server); |
255 } | 254 } |
256 | 255 |
257 static String _getCodeString(code) { | 256 static String _getCodeString(code) { |
258 if (code is List<String>) { | 257 if (code is List<String>) { |
259 code = code.join('\n'); | 258 code = code.join('\n'); |
260 } | 259 } |
261 return code as String; | 260 return code as String; |
262 } | 261 } |
263 } | 262 } |
OLD | NEW |