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

Side by Side Diff: pkg/analysis_services/lib/src/generated/change.dart

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library services.change;
9
10 import 'dart:collection';
11 import 'package:analyzer/src/generated/java_io.dart' show JavaFile;
12 import 'package:analyzer/src/generated/source.dart';
13
14 /**
15 * Describes some abstract operation to perform.
16 *
17 * [Change] implementations in "services" plugin cannot perform operation themse lves, they are
18 * just descriptions of operation. Actual operation should be performed by clien t.
19 */
20 abstract class Change {
21 final String name;
22
23 Change(this.name);
24 }
25
26 /**
27 * Composition of several [Change]s.
28 */
29 class CompositeChange extends Change {
30 List<Change> _children = [];
31
32 CompositeChange(String name, [Iterable<Change> changes]) : super(name) {
33 if (changes != null) {
34 _children.addAll(changes);
35 }
36 }
37
38 /**
39 * Adds given [Change]s.
40 */
41 void add(List<Change> changes) {
42 _children.addAll(changes);
43 }
44
45 /**
46 * @return the children [Change]s.
47 */
48 List<Change> get children => _children;
49 }
50
51 /**
52 * [Change] to create new file.
53 */
54 class CreateFileChange extends Change {
55 final JavaFile file;
56
57 final String content;
58
59 CreateFileChange(String name, this.file, this.content) : super(name);
60 }
61
62 /**
63 * Describes a text edit. Edits are executed by applying them to a [Source].
64 */
65 class Edit {
66 /**
67 * The offset at which to apply the edit.
68 */
69 final int offset;
70
71 /**
72 * The length of the text interval to replace.
73 */
74 final int length;
75
76 /**
77 * The replacement text.
78 */
79 final String replacement;
80
81 /**
82 * Create an edit.
83 *
84 * @param offset the offset at which to apply the edit
85 * @param length the length of the text interval replace
86 * @param replacement the replacement text
87 */
88 Edit(this.offset, this.length, this.replacement);
89
90 /**
91 * Create an edit.
92 *
93 * @param range the [SourceRange] to replace
94 * @param replacement the replacement text
95 */
96 Edit.range(SourceRange range, String replacement) : this(range.offset, range.l ength, replacement);
97
98 @override
99 String toString() => "${(offset < 0 ? "(" : "X(")}offset: ${offset}, length ${ length}, replacement :>${replacement}<:)";
100 }
101
102 /**
103 * Composition of two [CompositeChange]s. First change should be displayed in pr eview, but
104 * merged into second one before execution.
105 */
106 class MergeCompositeChange extends Change {
107 final CompositeChange previewChange;
108
109 final CompositeChange executeChange;
110
111 MergeCompositeChange(String name, this.previewChange, this.executeChange) : su per(name);
112 }
113
114 /**
115 * [Change] to apply to single [Source].
116 */
117 class SourceChange extends Change {
118 final Source source;
119
120 final List<Edit> edits = [];
121
122 Map<String, List<Edit>> _editGroups = new LinkedHashMap();
123
124 /**
125 * @param name the name of this change to display in UI
126 * @param source the [Source] to change
127 */
128 SourceChange(String name, this.source) : super(name);
129
130 /**
131 * Adds the [Edit] to apply.
132 */
133 void addEdit(Edit edit, [String description = '']) {
134 // add to all edits
135 edits.add(edit);
136 // add to group
137 {
138 List<Edit> group = _editGroups[description];
139 if (group == null) {
140 group = [];
141 _editGroups[description] = group;
142 }
143 group.add(edit);
144 }
145 }
146
147 /**
148 * @return the [Edit]s grouped by their descriptions.
149 */
150 Map<String, List<Edit>> get editGroups => _editGroups;
151 }
152
153 /**
154 * Manages multiple [SourceChange] objects.
155 */
156 class SourceChangeManager {
157 Map<Source, SourceChange> _changeMap = {};
158
159 /**
160 * @return the [SourceChange] to record modifications for given [Source].
161 */
162 SourceChange get(Source source) {
163 SourceChange change = _changeMap[source];
164 if (change == null) {
165 change = new SourceChange(source.shortName, source);
166 _changeMap[source] = change;
167 }
168 return change;
169 }
170
171 /**
172 * @return all [SourceChange] in this manager.
173 */
174 List<SourceChange> get changes {
175 Iterable<SourceChange> changes = _changeMap.values;
176 return new List.from(changes);
177 }
178 }
OLDNEW
« no previous file with comments | « pkg/analysis_services/lib/src/correction/util.dart ('k') | pkg/analysis_services/lib/src/generated/completion.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698