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 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
11 import 'package:analysis_server/plugin/protocol/protocol.dart' | 11 import 'package:analysis_server/plugin/protocol/protocol.dart' |
12 hide AnalysisError; | 12 hide AnalysisError; |
13 import 'package:analysis_server/src/services/correction/fix.dart'; | 13 import 'package:analysis_server/src/services/correction/fix.dart'; |
14 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 14 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| 15 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
15 import 'package:analyzer/error/error.dart'; | 16 import 'package:analyzer/error/error.dart'; |
16 import 'package:analyzer/file_system/file_system.dart'; | 17 import 'package:analyzer/file_system/file_system.dart'; |
17 import 'package:analyzer/source/package_map_resolver.dart'; | 18 import 'package:analyzer/source/package_map_resolver.dart'; |
18 import 'package:analyzer/src/error/codes.dart'; | 19 import 'package:analyzer/src/error/codes.dart'; |
19 import 'package:analyzer/src/generated/parser.dart'; | 20 import 'package:analyzer/src/generated/parser.dart'; |
20 import 'package:analyzer/src/generated/source.dart'; | 21 import 'package:analyzer/src/generated/source.dart'; |
21 import 'package:test/test.dart'; | 22 import 'package:test/test.dart'; |
22 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 23 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
23 | 24 |
24 import '../../abstract_context.dart'; | 25 import '../../abstract_context.dart'; |
(...skipping 5271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5296 change = fix.change; | 5297 change = fix.change; |
5297 // apply to "file" | 5298 // apply to "file" |
5298 List<SourceFileEdit> fileEdits = change.edits; | 5299 List<SourceFileEdit> fileEdits = change.edits; |
5299 expect(fileEdits, hasLength(1)); | 5300 expect(fileEdits, hasLength(1)); |
5300 resultCode = SourceEdit.applySequence(testCode, change.edits[0].edits); | 5301 resultCode = SourceEdit.applySequence(testCode, change.edits[0].edits); |
5301 } | 5302 } |
5302 | 5303 |
5303 void findLint(String src, String lintCode, {int length: 1}) { | 5304 void findLint(String src, String lintCode, {int length: 1}) { |
5304 int errorOffset = src.indexOf('/*LINT*/'); | 5305 int errorOffset = src.indexOf('/*LINT*/'); |
5305 resolveTestUnit(src.replaceAll('/*LINT*/', '')); | 5306 resolveTestUnit(src.replaceAll('/*LINT*/', '')); |
5306 error = new AnalysisError(testUnit.element.source, errorOffset, length, | 5307 error = new AnalysisError( |
| 5308 resolutionMap.elementForCompilationUnit(testUnit).source, |
| 5309 errorOffset, |
| 5310 length, |
5307 new LintCode(lintCode, '<ignored>')); | 5311 new LintCode(lintCode, '<ignored>')); |
5308 } | 5312 } |
5309 | 5313 |
5310 test_lint_addMissingOverride_field() async { | 5314 test_lint_addMissingOverride_field() async { |
5311 String src = ''' | 5315 String src = ''' |
5312 class abstract Test { | 5316 class abstract Test { |
5313 int get t; | 5317 int get t; |
5314 } | 5318 } |
5315 class Sub extends Test { | 5319 class Sub extends Test { |
5316 int /*LINT*/t = 42; | 5320 int /*LINT*/t = 42; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5503 var v = 42; | 5507 var v = 42; |
5504 print('v: $v'); | 5508 print('v: $v'); |
5505 } | 5509 } |
5506 '''); | 5510 '''); |
5507 } | 5511 } |
5508 | 5512 |
5509 void verifyResult(String expectedResult) { | 5513 void verifyResult(String expectedResult) { |
5510 expect(resultCode, expectedResult); | 5514 expect(resultCode, expectedResult); |
5511 } | 5515 } |
5512 } | 5516 } |
OLD | NEW |