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

Side by Side Diff: pkg/analyzer_plugin/test/plugin/fix_mixin_test.dart

Issue 2953093002: Update the plugin API (Closed)
Patch Set: Update FixesRequest Created 3 years, 6 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/analysis/results.dart' hide AnalysisResult;
8 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/src/dart/analysis/driver.dart'; 10 import 'package:analyzer/src/dart/analysis/driver.dart';
12 import 'package:analyzer/src/error/codes.dart'; 11 import 'package:analyzer/src/error/codes.dart';
13 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer_plugin/plugin/fix_mixin.dart'; 13 import 'package:analyzer_plugin/plugin/fix_mixin.dart';
15 import 'package:analyzer_plugin/protocol/protocol_common.dart' 14 import 'package:analyzer_plugin/protocol/protocol_common.dart'
16 hide AnalysisError; 15 hide AnalysisError;
17 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; 16 import 'package:analyzer_plugin/protocol/protocol_generated.dart';
17 import 'package:analyzer_plugin/src/utilities/fixes/fixes.dart';
18 import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; 18 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
19 import 'package:path/src/context.dart'; 19 import 'package:path/src/context.dart';
20 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; 21 import 'package:test_reflective_loader/test_reflective_loader.dart';
22 22
23 import 'mocks.dart'; 23 import 'mocks.dart';
24 24
25 void main() { 25 void main() {
26 defineReflectiveTests(FixesMixinTest); 26 defineReflectiveTests(FixesMixinTest);
27 } 27 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 class _TestFixContributor implements FixContributor { 66 class _TestFixContributor implements FixContributor {
67 List<PrioritizedSourceChange> changes; 67 List<PrioritizedSourceChange> changes;
68 68
69 _TestFixContributor(this.changes); 69 _TestFixContributor(this.changes);
70 70
71 @override 71 @override
72 void computeFixes(FixesRequest request, FixCollector collector) { 72 void computeFixes(FixesRequest request, FixCollector collector) {
73 for (PrioritizedSourceChange change in changes) { 73 for (PrioritizedSourceChange change in changes) {
74 collector.addFix(request.error, change); 74 collector.addFix(request.errorsToFix[0], change);
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 class _TestServerPlugin extends MockServerPlugin with FixesMixin { 79 class _TestServerPlugin extends MockServerPlugin with FixesMixin {
80 _TestServerPlugin(ResourceProvider resourceProvider) 80 _TestServerPlugin(ResourceProvider resourceProvider)
81 : super(resourceProvider); 81 : super(resourceProvider);
82 82
83 PrioritizedSourceChange createChange() { 83 PrioritizedSourceChange createChange() {
84 return new PrioritizedSourceChange(0, new SourceChange('')); 84 return new PrioritizedSourceChange(0, new SourceChange(''));
85 } 85 }
86 86
87 @override 87 @override
88 List<FixContributor> getFixContributors(AnalysisDriverGeneric driver) { 88 List<FixContributor> getFixContributors(AnalysisDriverGeneric driver) {
89 return <FixContributor>[ 89 return <FixContributor>[
90 new _TestFixContributor(<PrioritizedSourceChange>[createChange()]), 90 new _TestFixContributor(<PrioritizedSourceChange>[createChange()]),
91 new _TestFixContributor( 91 new _TestFixContributor(
92 <PrioritizedSourceChange>[createChange(), createChange()]) 92 <PrioritizedSourceChange>[createChange(), createChange()])
93 ]; 93 ];
94 } 94 }
95 95
96 @override 96 @override
97 Future<ResolveResult> getResolveResultForFixes( 97 Future<FixesRequest> getFixesRequest(EditGetFixesParams parameters,
98 AnalysisDriverGeneric driver, String path) async { 98 covariant AnalysisDriverGeneric driver) async {
99 int offset = parameters.offset;
99 AnalysisError error = new AnalysisError( 100 AnalysisError error = new AnalysisError(
100 new MockSource(), 0, 0, CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT); 101 new MockSource(), 0, 0, CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT);
101 return new AnalysisResult(null, null, null, null, null, null, 102 AnalysisResult result = new AnalysisResult(null, null, null, null, null,
102 new LineInfo([0, 20]), null, null, [error], null); 103 null, new LineInfo([0, 20]), null, null, [error], null);
104 return new DartFixesRequestImpl(resourceProvider, offset, [error], result);
103 } 105 }
104 } 106 }
OLDNEW
« no previous file with comments | « pkg/analyzer_plugin/test/plugin/completion_mixin_test.dart ('k') | pkg/analyzer_plugin/test/plugin/mocks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698