| 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.correction.assist; | 5 library test.services.correction.assist; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/correction/assist.dart'; | 8 import 'package:analysis_server/src/services/correction/assist.dart'; |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 '''); | 197 '''); |
| 198 assertHasAssistAt('item in', AssistKind.ADD_TYPE_ANNOTATION, ''' | 198 assertHasAssistAt('item in', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 199 main(List<String> items) { | 199 main(List<String> items) { |
| 200 for (final String item in items) { | 200 for (final String item in items) { |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 '''); | 203 '''); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void test_addTypeAnnotation_local_OK_onVariableDeclarationStatement() { |
| 207 _indexTestUnit(''' |
| 208 main() { |
| 209 var v = 123; // marker |
| 210 } |
| 211 '''); |
| 212 assertHasAssistAt(' // marker', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 213 main() { |
| 214 int v = 123; // marker |
| 215 } |
| 216 '''); |
| 217 } |
| 218 |
| 206 void test_addTypeAnnotation_local_OK_Function() { | 219 void test_addTypeAnnotation_local_OK_Function() { |
| 207 _indexTestUnit(''' | 220 _indexTestUnit(''' |
| 208 main() { | 221 main() { |
| 209 var v = () => 1; | 222 var v = () => 1; |
| 210 } | 223 } |
| 211 '''); | 224 '''); |
| 212 assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, ''' | 225 assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 213 main() { | 226 main() { |
| 214 Function v = () => 1; | 227 Function v = () => 1; |
| 215 } | 228 } |
| (...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 void _indexTestUnit(String code) { | 2433 void _indexTestUnit(String code) { |
| 2421 resolveTestUnit(code); | 2434 resolveTestUnit(code); |
| 2422 index.indexUnit(context, testUnit); | 2435 index.indexUnit(context, testUnit); |
| 2423 } | 2436 } |
| 2424 | 2437 |
| 2425 void _setStartEndSelection() { | 2438 void _setStartEndSelection() { |
| 2426 offset = findOffset('// start\n') + '// start\n'.length; | 2439 offset = findOffset('// start\n') + '// start\n'.length; |
| 2427 length = findOffset('// end') - offset; | 2440 length = findOffset('// end') - offset; |
| 2428 } | 2441 } |
| 2429 } | 2442 } |
| OLD | NEW |