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

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

Issue 447613002: Make Change implementation consistent with the server spec. (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
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.fix; 5 library test.edit.fix;
6 6
7 import 'package:analysis_server/src/computer/element.dart'; 7 import 'package:analysis_server/src/computer/element.dart';
8 import 'package:analysis_server/src/computer/error.dart'; 8 import 'package:analysis_server/src/computer/error.dart';
9 import 'package:analysis_server/src/edit/fix.dart'; 9 import 'package:analysis_server/src/edit/fix.dart';
10 import 'package:analysis_services/constants.dart'; 10 import 'package:analysis_services/constants.dart';
(...skipping 23 matching lines...) Expand all
34 Index index; 34 Index index;
35 SearchEngineImpl searchEngine; 35 SearchEngineImpl searchEngine;
36 36
37 void setUp() { 37 void setUp() {
38 super.setUp(); 38 super.setUp();
39 index = createLocalMemoryIndex(); 39 index = createLocalMemoryIndex();
40 searchEngine = new SearchEngineImpl(index); 40 searchEngine = new SearchEngineImpl(index);
41 verifyNoTestUnitErrors = false; 41 verifyNoTestUnitErrors = false;
42 } 42 }
43 43
44 void test_fromJson() {
45 var json = {
46 ERROR: {
47 SEVERITY: 'ERROR',
48 TYPE: 'SYNTACTIC_ERROR',
49 LOCATION: {
50 FILE: '/test.dart',
51 OFFSET: 19,
52 LENGTH: 1,
53 START_LINE: 2,
54 START_COLUMN: 11
55 },
56 MESSAGE: 'Expected to find \';\''
57 },
58 FIXES: [{
59 MESSAGE: 'Insert \';\'',
60 EDITS: [{
61 FILE: '/test.dart',
62 EDITS: [{
63 OFFSET: 20,
64 LENGTH: 0,
65 REPLACEMENT: ';'
66 }]
67 }],
68 LINKED_POSITION_GROUPS: []
69 }]
70 };
71 ErrorFixes errorFixes = ErrorFixes.fromJson(json);
72 {
73 AnalysisError error = errorFixes.error;
74 expect(error.severity, 'ERROR');
75 expect(error.type, 'SYNTACTIC_ERROR');
76 expect(error.message, "Expected to find ';'");
77 {
78 Location location = error.location;
79 expect(location.file, testFile);
80 expect(location.offset, 19);
81 expect(location.length, 1);
82 expect(location.startLine, 2);
83 expect(location.startColumn, 11);
84 }
85 }
86 expect(errorFixes.fixes, hasLength(1));
87 {
88 Change change = errorFixes.fixes[0];
89 expect(change.message, "Insert ';'");
90 expect(change.edits, hasLength(1));
91 {
92 FileEdit fileEdit = change.edits[0];
93 expect(fileEdit.file, testFile);
94 expect(
95 fileEdit.edits.toString(),
96 "[Edit(offset=20, length=0, replacement=:>;<:)]");
97 }
98 }
99 expect(
100 errorFixes.toString(),
101 'ErrorFixes(error=AnalysisError('
102 'location=Location(file=/test.dart; offset=19; length=1; '
103 'startLine=2; startColumn=11) message=Expected to find \';\'; '
104 'severity=ERROR; type=SYNTACTIC_ERROR; correction=null, '
105 'fixes=[Change(message=Insert \';\', '
106 'edits=[FileEdit(file=/test.dart, edits=[Edit(offset=20, length=0, '
107 'replacement=:>;<:)])], linkedPositionGroups=[])])');
108 }
109
110 void test_fromService() { 44 void test_fromService() {
111 verifyNoTestUnitErrors = false; 45 verifyNoTestUnitErrors = false;
112 resolveTestUnit(''' 46 resolveTestUnit('''
113 main() { 47 main() {
114 print(42) 48 print(42)
115 } 49 }
116 '''); 50 ''');
117 engine.AnalysisErrorInfo errors = context.getErrors(testSource); 51 engine.AnalysisErrorInfo errors = context.getErrors(testSource);
118 engine.AnalysisError engineError = errors.errors[0]; 52 engine.AnalysisError engineError = errors.errors[0];
119 List<services.Fix> servicesFixes = 53 List<services.Fix> servicesFixes =
(...skipping 18 matching lines...) Expand all
138 FIXES: [{ 72 FIXES: [{
139 MESSAGE: 'Insert \';\'', 73 MESSAGE: 'Insert \';\'',
140 EDITS: [{ 74 EDITS: [{
141 FILE: '/test.dart', 75 FILE: '/test.dart',
142 EDITS: [{ 76 EDITS: [{
143 OFFSET: 20, 77 OFFSET: 20,
144 LENGTH: 0, 78 LENGTH: 0,
145 REPLACEMENT: ';' 79 REPLACEMENT: ';'
146 }] 80 }]
147 }], 81 }],
148 LINKED_POSITION_GROUPS: [] 82 LINKED_EDIT_GROUPS: []
149 }] 83 }]
150 }); 84 });
151 } 85 }
152 } 86 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/edit/fix.dart ('k') | pkg/analysis_server/test/edit/fixes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698