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

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

Issue 1764853002: Quick fix to ignore a specific error (#25915). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixes Created 4 years, 9 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
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/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/domain_analysis.dart'; 10 import 'package:analysis_server/src/domain_analysis.dart';
11 import 'package:analysis_server/src/edit/edit_domain.dart'; 11 import 'package:analysis_server/src/edit/edit_domain.dart';
12 import 'package:analysis_server/src/services/correction/fix.dart';
12 import 'package:plugin/manager.dart'; 13 import 'package:plugin/manager.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 14 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 import 'package:unittest/unittest.dart' hide ERROR; 15 import 'package:unittest/unittest.dart' hide ERROR;
15 16
16 import '../analysis_abstract.dart'; 17 import '../analysis_abstract.dart';
17 import '../mocks.dart'; 18 import '../mocks.dart';
18 import '../utils.dart'; 19 import '../utils.dart';
19 20
20 main() { 21 main() {
21 initializeTestEnvironment(); 22 initializeTestEnvironment();
22 defineReflectiveTests(FixesTest); 23 defineReflectiveTests(FixesTest);
23 } 24 }
24 25
25 @reflectiveTest 26 @reflectiveTest
26 class FixesTest extends AbstractAnalysisTest { 27 class FixesTest extends AbstractAnalysisTest {
27 @override 28 @override
28 void setUp() { 29 void setUp() {
29 super.setUp(); 30 super.setUp();
30 createProject(); 31 createProject();
31 ExtensionManager manager = new ExtensionManager(); 32 ExtensionManager manager = new ExtensionManager();
32 manager.processPlugins([server.serverPlugin]); 33 manager.processPlugins([server.serverPlugin]);
33 handler = new EditDomainHandler(server); 34 handler = new EditDomainHandler(server);
34 } 35 }
35 36
36 test_fixUndefinedClass() async { 37 test_fixUndefinedClass() async {
37 addTestFile(''' 38 addTestFile('''
38 main() { 39 main() {
39 Future<String> x = null; 40 Future<String> x = null;
41 print(x);
scheglov 2016/03/04 18:55:20 Why do we need this statement?
pquitslund 2016/03/04 19:09:39 Without it, we get an `unused_local_variable` hint
40 } 42 }
41 '''); 43 ''');
42 await waitForTasksFinished(); 44 await waitForTasksFinished();
43 List<AnalysisErrorFixes> errorFixes = await _getFixesAt('Future<String>'); 45 List<AnalysisErrorFixes> errorFixes = await _getFixesAt('Future<String>');
44 expect(errorFixes, hasLength(1)); 46 expect(errorFixes, hasLength(1));
45 AnalysisError error = errorFixes[0].error; 47 AnalysisError error = errorFixes[0].error;
46 expect(error.severity, AnalysisErrorSeverity.WARNING); 48 expect(error.severity, AnalysisErrorSeverity.WARNING);
47 expect(error.type, AnalysisErrorType.STATIC_WARNING); 49 expect(error.type, AnalysisErrorType.STATIC_WARNING);
48 List<SourceChange> fixes = errorFixes[0].fixes; 50 List<SourceChange> fixes = errorFixes[0].fixes;
49 expect(fixes, hasLength(2)); 51 expect(fixes, hasLength(3));
50 expect(fixes[0].message, matches('Import library')); 52 expect(fixes[0].message, matches('Import library'));
51 expect(fixes[1].message, matches('Create class')); 53 expect(fixes[1].message, matches('Create class'));
54 expect(
55 fixes[2].message, matches("Ignore error with code 'undefined_class'"));
52 } 56 }
53 57
54 test_hasFixes() async { 58 test_hasFixes() async {
55 addTestFile(''' 59 addTestFile('''
56 foo() { 60 foo() {
57 print(1) 61 print(1)
58 } 62 }
59 bar() { 63 bar() {
60 print(10) print(20) 64 print(10) print(20)
61 } 65 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return await _getFixes(offset); 113 return await _getFixes(offset);
110 } 114 }
111 115
112 void _isSyntacticErrorWithSingleFix(AnalysisErrorFixes fixes) { 116 void _isSyntacticErrorWithSingleFix(AnalysisErrorFixes fixes) {
113 AnalysisError error = fixes.error; 117 AnalysisError error = fixes.error;
114 expect(error.severity, AnalysisErrorSeverity.ERROR); 118 expect(error.severity, AnalysisErrorSeverity.ERROR);
115 expect(error.type, AnalysisErrorType.SYNTACTIC_ERROR); 119 expect(error.type, AnalysisErrorType.SYNTACTIC_ERROR);
116 expect(fixes.fixes, hasLength(1)); 120 expect(fixes.fixes, hasLength(1));
117 } 121 }
118 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698