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

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

Issue 2830903004: Add support for converting from server to plugin protocol objects (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
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/plugin/request_converter_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:analysis_server/plugin/protocol/protocol.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;
8
9 /**
10 * An object used to convert between similar objects defined by both the plugin
11 * protocol and the server protocol.
12 */
13 class RequestConverter {
14 plugin.AnalysisService convertAnalysisService(
15 server.AnalysisService service) {
16 return new plugin.AnalysisService(service.name);
17 }
18
19 Object convertFileOverlay(Object overlay) {
20 if (overlay is server.AddContentOverlay) {
21 return new plugin.AddContentOverlay(overlay.content);
22 } else if (overlay is server.ChangeContentOverlay) {
23 return new plugin.ChangeContentOverlay(
24 overlay.edits.map(convertSourceEdit).toList());
25 } else if (overlay is server.RemoveContentOverlay) {
26 return new plugin.RemoveContentOverlay();
27 }
28 return null;
29 }
30
31 plugin.SourceEdit convertSourceEdit(server.SourceEdit edit) {
32 return new plugin.SourceEdit(edit.offset, edit.length, edit.replacement);
33 }
34 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/src/plugin/request_converter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698