| 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.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 8 import 'package:analysis_server/src/services/correction/fix.dart'; | 8 import 'package:analysis_server/src/services/correction/fix.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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 method() {} | 390 method() {} |
| 391 } | 391 } |
| 392 main() { | 392 main() { |
| 393 new A.named(1, 2.0); | 393 new A.named(1, 2.0); |
| 394 } | 394 } |
| 395 '''); | 395 '''); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void test_createFile_forImport() { |
| 399 testFile = '/my/project/bin/test.dart'; |
| 400 _indexTestUnit(''' |
| 401 import 'my_file.dart'; |
| 402 '''); |
| 403 AnalysisError error = _findErrorToFix(); |
| 404 fix = _assertHasFix(FixKind.CREATE_FILE, error); |
| 405 change = fix.change; |
| 406 // validate change |
| 407 List<SourceFileEdit> fileEdits = change.edits; |
| 408 expect(fileEdits, hasLength(1)); |
| 409 SourceFileEdit fileEdit = change.edits[0]; |
| 410 expect(fileEdit.file, '/my/project/bin/my_file.dart'); |
| 411 expect(fileEdit.fileStamp, -1); |
| 412 expect(fileEdit.edits[0].replacement, contains('library my.file;')); |
| 413 } |
| 414 |
| 398 void test_createMissingOverrides_functionType() { | 415 void test_createMissingOverrides_functionType() { |
| 399 _indexTestUnit(''' | 416 _indexTestUnit(''' |
| 400 abstract class A { | 417 abstract class A { |
| 401 forEach(int f(double p1, String p2)); | 418 forEach(int f(double p1, String p2)); |
| 402 } | 419 } |
| 403 | 420 |
| 404 class B extends A { | 421 class B extends A { |
| 405 } | 422 } |
| 406 '''); | 423 '''); |
| 407 assertHasFix(FixKind.CREATE_MISSING_OVERRIDES, ''' | 424 assertHasFix(FixKind.CREATE_MISSING_OVERRIDES, ''' |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 positions.add(new Position(testFile, offset)); | 2008 positions.add(new Position(testFile, offset)); |
| 1992 } | 2009 } |
| 1993 return positions; | 2010 return positions; |
| 1994 } | 2011 } |
| 1995 | 2012 |
| 1996 void _indexTestUnit(String code) { | 2013 void _indexTestUnit(String code) { |
| 1997 resolveTestUnit(code); | 2014 resolveTestUnit(code); |
| 1998 index.indexUnit(context, testUnit); | 2015 index.indexUnit(context, testUnit); |
| 1999 } | 2016 } |
| 2000 } | 2017 } |
| OLD | NEW |