Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: pkg/analysis_server/test/edit/fixes_test.dart

Issue 494153003: Return only fixes for the errors on the line of the given offset. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.edit.fixes; 5 library test.edit.fixes;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/edit/edit_domain.dart'; 9 import 'package:analysis_server/src/edit/edit_domain.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 14 matching lines...) Expand all
25 class FixesTest extends AbstractAnalysisTest { 25 class FixesTest extends AbstractAnalysisTest {
26 @override 26 @override
27 void setUp() { 27 void setUp() {
28 super.setUp(); 28 super.setUp();
29 createProject(); 29 createProject();
30 handler = new EditDomainHandler(server); 30 handler = new EditDomainHandler(server);
31 } 31 }
32 32
33 Future test_hasFixes() { 33 Future test_hasFixes() {
34 addTestFile(''' 34 addTestFile('''
35 main() { 35 foo() {
36 print(42) 36 print(1)
37 }
38 bar() {
39 print(10) print(20)
37 } 40 }
38 '''); 41 ''');
39 return waitForTasksFinished().then((_) { 42 return waitForTasksFinished().then((_) {
40 Request request = new EditGetFixesParams(testFile, 43 // print(1)
41 findOffset('print')).toRequest('0');
42 Response response = handleSuccessfulRequest(request);
43 var result = new EditGetFixesResult.fromResponse(response);
44 List<ErrorFixes> errorFixes = result.fixes;
45 expect(errorFixes, hasLength(1));
46 { 44 {
47 ErrorFixes fixes = errorFixes[0]; 45 List<ErrorFixes> errorFixes = _getFixesAt('print(1)');
48 AnalysisError error = fixes.error; 46 expect(errorFixes, hasLength(1));
49 expect(error.severity, ErrorSeverity.ERROR); 47 _isSyntacticErrorWithSingleFix(errorFixes[0]);
50 expect(error.type, ErrorType.SYNTACTIC_ERROR); 48 }
51 expect(fixes.fixes, hasLength(1)); 49 // print(10)
50 {
51 List<ErrorFixes> errorFixes = _getFixesAt('print(10)');
52 expect(errorFixes, hasLength(2));
53 _isSyntacticErrorWithSingleFix(errorFixes[0]);
54 _isSyntacticErrorWithSingleFix(errorFixes[1]);
52 } 55 }
53 }); 56 });
54 } 57 }
58
59 void _isSyntacticErrorWithSingleFix(ErrorFixes fixes) {
60 AnalysisError error = fixes.error;
61 expect(error.severity, ErrorSeverity.ERROR);
62 expect(error.type, ErrorType.SYNTACTIC_ERROR);
63 expect(fixes.fixes, hasLength(1));
64 }
65
66 List<ErrorFixes> _getFixesAt(String search) {
67 int offset = findOffset(search);
68 return _getFixes(offset);
69 }
70
71
72 List<ErrorFixes> _getFixes(int offset) {
73 Request request = new EditGetFixesParams(testFile, offset).toRequest('0');
74 Response response = handleSuccessfulRequest(request);
75 var result = new EditGetFixesResult.fromResponse(response);
76 return result.fixes;
77 }
55 } 78 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698