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

Side by Side Diff: pkg/analysis_server/lib/src/plugin/request_converter.dart

Issue 2834993002: Add support for three more plugin requests (Closed)
Patch Set: Created 3 years, 8 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 'package:analysis_server/plugin/protocol/protocol.dart' as server; 5 import 'package:analysis_server/plugin/protocol/protocol.dart' as server;
6 import 'package:analysis_server/src/protocol/protocol_internal.dart' as server; 6 import 'package:analysis_server/src/protocol/protocol_internal.dart' as server;
7 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; 7 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
8 8
9 /** 9 /**
10 * An object used to convert between similar objects defined by both the plugin 10 * An object used to convert between similar objects defined by both the plugin
11 * protocol and the server protocol. 11 * protocol and the server protocol.
12 */ 12 */
13 class RequestConverter { 13 class RequestConverter {
14 plugin.AnalysisService convertAnalysisService( 14 plugin.AnalysisService convertAnalysisService(
15 server.AnalysisService service) { 15 server.AnalysisService service) {
16 return new plugin.AnalysisService(service.name); 16 return new plugin.AnalysisService(service.name);
17 } 17 }
18 18
19 plugin.AnalysisSetPriorityFilesParams convertAnalysisSetPriorityFilesParams(
20 server.AnalysisSetPriorityFilesParams params) {
21 return new plugin.AnalysisSetPriorityFilesParams(params.files);
22 }
23
24 plugin.AnalysisSetSubscriptionsParams convertAnalysisSetSubscriptionsParams(
25 server.AnalysisSetSubscriptionsParams params) {
26 Map<server.AnalysisService, List<String>> serverSubscriptions =
27 params.subscriptions;
28 Map<plugin.AnalysisService, List<String>> pluginSubscriptions =
29 <plugin.AnalysisService, List<String>>{};
30 for (server.AnalysisService service in serverSubscriptions.keys) {
31 try {
32 pluginSubscriptions[convertAnalysisService(service)] =
33 serverSubscriptions[service];
34 } catch (exception) {
35 // Ignore the exception. It indicates that the service isn't one that
36 // should be passed along to plugins.
37 }
38 }
39 return new plugin.AnalysisSetSubscriptionsParams(pluginSubscriptions);
40 }
41
42 plugin.AnalysisUpdateContentParams convertAnalysisUpdateContentParams(
43 server.AnalysisUpdateContentParams params) {
44 Map<String, dynamic> serverOverlays = params.files;
45 Map<String, dynamic> pluginOverlays = <String, dynamic>{};
46 for (String file in serverOverlays.keys) {
47 pluginOverlays[file] = convertFileOverlay(serverOverlays[file]);
48 }
49 return new plugin.AnalysisUpdateContentParams(pluginOverlays);
50 }
51
19 Object convertFileOverlay(Object overlay) { 52 Object convertFileOverlay(Object overlay) {
20 if (overlay is server.AddContentOverlay) { 53 if (overlay is server.AddContentOverlay) {
21 return new plugin.AddContentOverlay(overlay.content); 54 return new plugin.AddContentOverlay(overlay.content);
22 } else if (overlay is server.ChangeContentOverlay) { 55 } else if (overlay is server.ChangeContentOverlay) {
23 return new plugin.ChangeContentOverlay( 56 return new plugin.ChangeContentOverlay(
24 overlay.edits.map(convertSourceEdit).toList()); 57 overlay.edits.map(convertSourceEdit).toList());
25 } else if (overlay is server.RemoveContentOverlay) { 58 } else if (overlay is server.RemoveContentOverlay) {
26 return new plugin.RemoveContentOverlay(); 59 return new plugin.RemoveContentOverlay();
27 } 60 }
28 return null; 61 return null;
29 } 62 }
30 63
31 plugin.SourceEdit convertSourceEdit(server.SourceEdit edit) { 64 plugin.SourceEdit convertSourceEdit(server.SourceEdit edit) {
32 return new plugin.SourceEdit(edit.offset, edit.length, edit.replacement); 65 return new plugin.SourceEdit(edit.offset, edit.length, edit.replacement);
33 } 66 }
34 } 67 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/plugin_manager.dart ('k') | pkg/analysis_server/test/analysis/set_priority_files_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698