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

Side by Side Diff: pkg/analysis_server/lib/src/domain_context.dart

Issue 308703005: Extract constants into separate libarary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
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 domain.context; 5 library domain.context;
6 6
7 import 'package:analysis_server/src/analysis_server.dart'; 7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
11 12
12 /** 13 /**
13 * Instances of the class [ContextDomainHandler] implement a [RequestHandler] 14 * Instances of the class [ContextDomainHandler] implement a [RequestHandler]
14 * that handles requests in the context domain. 15 * that handles requests in the context domain.
15 * 16 *
16 * TODO(scheglov) this class is replaces with [AnalysisDomainHandler]. 17 * TODO(scheglov) this class is replaces with [AnalysisDomainHandler].
17 */ 18 */
18 class ContextDomainHandler implements RequestHandler { 19 class ContextDomainHandler implements RequestHandler {
19 /** 20 /**
20 * The name of the context.applyChanges request.
21 */
22 static const String APPLY_CHANGES_NAME = 'context.applyChanges';
23
24 /**
25 * The name of the context.getFixes request.
26 */
27 static const String GET_FIXES_NAME = 'context.getFixes';
28
29 /**
30 * The name of the context.setOptions request.
31 */
32 static const String SET_OPTIONS_NAME = 'context.setOptions';
33
34 /**
35 * The name of the context.setPrioritySources request.
36 */
37 static const String SET_PRIORITY_SOURCES_NAME = 'context.setPrioritySources';
38
39 /**
40 * The name of the added parameter.
41 */
42 static const String ADDED_PARAM = "added";
43
44 /**
45 * The name of the changes parameter.
46 */
47 static const String CHANGES_PARAM = 'changes';
48
49 /**
50 * The name of the contextId parameter.
51 */
52 static const String CONTEXT_ID_PARAM = 'contextId';
53
54 /**
55 * The name of the modified parameter.
56 */
57 static const String MODIFIED_PARAM = "modified";
58
59 /**
60 * The name of the options parameter.
61 */
62 static const String OPTIONS_PARAM = 'options';
63
64 /**
65 * The name of the removed parameter.
66 */
67 static const String REMOVED_PARAM = "removed";
68
69 /**
70 * The name of the sources parameter.
71 */
72 static const String SOURCES_PARAM = 'sources';
73
74 /**
75 * The name of the cacheSize option.
76 */
77 static const String CACHE_SIZE_OPTION = 'cacheSize';
78
79 /**
80 * The name of the generateHints option.
81 */
82 static const String GENERATE_HINTS_OPTION = 'generateHints';
83
84 /**
85 * The name of the generateDart2jsHints option.
86 */
87 static const String GENERATE_DART2JS_OPTION = 'generateDart2jsHints';
88
89 /**
90 * The name of the provideErrors option.
91 */
92 static const String PROVIDE_ERRORS_OPTION = 'provideErrors';
93
94 /**
95 * The name of the provideNavigation option.
96 */
97 static const String PROVIDE_NAVIGATION_OPTION = 'provideNavigation';
98
99 /**
100 * The name of the provideOutline option.
101 */
102 static const String PROVIDE_OUTLINE_OPTION = 'provideOutline';
103
104 /**
105 * The analysis server that is using this handler to process requests. 21 * The analysis server that is using this handler to process requests.
106 */ 22 */
107 final AnalysisServer server; 23 final AnalysisServer server;
108 24
109 /** 25 /**
110 * Initialize a newly created handler to handle requests for the given [server ]. 26 * Initialize a newly created handler to handle requests for the given [server ].
111 */ 27 */
112 ContextDomainHandler(this.server); 28 ContextDomainHandler(this.server);
113 29
114 @override 30 @override
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return response; 65 return response;
150 } 66 }
151 67
152 /** 68 /**
153 * Convert the given JSON object into a [ChangeSet], using the given 69 * Convert the given JSON object into a [ChangeSet], using the given
154 * [sourceFactory] to convert the embedded strings into sources. 70 * [sourceFactory] to convert the embedded strings into sources.
155 */ 71 */
156 ChangeSet createChangeSet(Request request, SourceFactory sourceFactory, 72 ChangeSet createChangeSet(Request request, SourceFactory sourceFactory,
157 RequestDatum jsonData) { 73 RequestDatum jsonData) {
158 ChangeSet changeSet = new ChangeSet(); 74 ChangeSet changeSet = new ChangeSet();
159 if (jsonData.hasKey(ADDED_PARAM)) { 75 if (jsonData.hasKey(ADDED)) {
160 convertSources(request, sourceFactory, jsonData[ADDED_PARAM], (Source sour ce) { 76 convertSources(request, sourceFactory, jsonData[ADDED], (Source source) {
161 changeSet.addedSource(source); 77 changeSet.addedSource(source);
162 }); 78 });
163 } 79 }
164 if (jsonData.hasKey(MODIFIED_PARAM)) { 80 if (jsonData.hasKey(MODIFIED_PARAM)) {
165 convertSources(request, sourceFactory, jsonData[MODIFIED_PARAM], (Source s ource) { 81 convertSources(request, sourceFactory, jsonData[MODIFIED_PARAM], (Source s ource) {
166 changeSet.changedSource(source); 82 changeSet.changedSource(source);
167 }); 83 });
168 } 84 }
169 if (jsonData.hasKey(REMOVED_PARAM)) { 85 if (jsonData.hasKey(REMOVED)) {
170 convertSources(request, sourceFactory, jsonData[REMOVED_PARAM], (Source so urce) { 86 convertSources(request, sourceFactory, jsonData[REMOVED], (Source source) {
171 changeSet.removedSource(source); 87 changeSet.removedSource(source);
172 }); 88 });
173 } 89 }
174 return changeSet; 90 return changeSet;
175 } 91 }
176 92
177 /** 93 /**
178 * If the given [sources] is a list of strings, use the given [sourceFactory] 94 * If the given [sources] is a list of strings, use the given [sourceFactory]
179 * to convert each string into a source and pass the source to the given 95 * to convert each string into a source and pass the source to the given
180 * [handler]. Otherwise, throw an exception indicating that the data in the 96 * [handler]. Otherwise, throw an exception indicating that the data in the
(...skipping 23 matching lines...) Expand all
204 context.analysisOptions = createAnalysisOptions(request); 120 context.analysisOptions = createAnalysisOptions(request);
205 Response response = new Response(request.id); 121 Response response = new Response(request.id);
206 return response; 122 return response;
207 } 123 }
208 124
209 /** 125 /**
210 * Return the set of analysis options associated with the given [request], or 126 * Return the set of analysis options associated with the given [request], or
211 * throw a [RequestFailure] exception if the analysis options are not valid. 127 * throw a [RequestFailure] exception if the analysis options are not valid.
212 */ 128 */
213 AnalysisOptions createAnalysisOptions(Request request) { 129 AnalysisOptions createAnalysisOptions(Request request) {
214 RequestDatum optionsData = request.getRequiredParameter(OPTIONS_PARAM); 130 RequestDatum optionsData = request.getRequiredParameter(OPTIONS);
215 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 131 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
216 optionsData.forEachMap((String key, RequestDatum value) { 132 optionsData.forEachMap((String key, RequestDatum value) {
217 if (key == CACHE_SIZE_OPTION) { 133 if (key == CACHE_SIZE_OPTION) {
218 options.cacheSize = value.asInt(); 134 options.cacheSize = value.asInt();
219 } else if (key == GENERATE_HINTS_OPTION) { 135 } else if (key == GENERATE_HINTS_OPTION) {
220 options.hint = value.asBool(); 136 options.hint = value.asBool();
221 } else if (key == GENERATE_DART2JS_OPTION) { 137 } else if (key == GENERATE_DART2JS_OPTION) {
222 options.dart2jsHint = value.asBool(); 138 options.dart2jsHint = value.asBool();
223 } else if (key == PROVIDE_ERRORS_OPTION) { 139 } else if (key == PROVIDE_ERRORS_OPTION) {
224 // options.provideErrors = value.asBool(); 140 // options.provideErrors = value.asBool();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // TODO(scheglov) remove it after migrating to the new API 184 // TODO(scheglov) remove it after migrating to the new API
269 return null; 185 return null;
270 // String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString (); 186 // String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString ();
271 // AnalysisContext context = server.contextMap[contextId]; 187 // AnalysisContext context = server.contextMap[contextId];
272 // if (context == null) { 188 // if (context == null) {
273 // throw new RequestFailure(new Response.contextDoesNotExist(request)); 189 // throw new RequestFailure(new Response.contextDoesNotExist(request));
274 // } 190 // }
275 // return context; 191 // return context;
276 } 192 }
277 } 193 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_analysis.dart ('k') | pkg/analysis_server/lib/src/domain_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698