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

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

Issue 3001413002: Remove uses of the old plugin model from the analysis server (Closed)
Patch Set: Created 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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/analysis/analysis_domain.dart';
6 import 'package:analysis_server/plugin/analysis/analyzed_files.dart';
7 import 'package:analysis_server/plugin/analysis/navigation/navigation.dart';
8 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart' ;
9 import 'package:analysis_server/plugin/analysis/occurrences/occurrences.dart';
10 import 'package:analysis_server/plugin/analysis/occurrences/occurrences_core.dar t';
11 import 'package:analysis_server/plugin/edit/assist/assist.dart';
12 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
13 import 'package:analysis_server/plugin/edit/fix/fix.dart';
14 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
15 import 'package:analysis_server/protocol/protocol.dart';
16 import 'package:analysis_server/src/analysis_server.dart';
17 import 'package:analysis_server/src/domain_analysis.dart';
18 import 'package:analysis_server/src/domain_analytics.dart';
19 import 'package:analysis_server/src/domain_completion.dart';
20 import 'package:analysis_server/src/domain_diagnostic.dart';
21 import 'package:analysis_server/src/domain_execution.dart';
22 import 'package:analysis_server/src/domain_kythe.dart';
23 import 'package:analysis_server/src/domain_server.dart';
24 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart';
25 import 'package:analysis_server/src/domains/analysis/occurrences_dart.dart';
26 import 'package:analysis_server/src/edit/edit_domain.dart';
27 import 'package:analysis_server/src/provisional/completion/completion_core.dart' ;
28 import 'package:analysis_server/src/search/search_domain.dart';
29 import 'package:analysis_server/src/services/correction/assist_internal.dart';
30 import 'package:analysis_server/src/services/correction/fix_internal.dart';
31 import 'package:analyzer/src/generated/engine.dart';
32 import 'package:plugin/plugin.dart';
33
34 /**
35 * A function that will create a request handler that can be used by the given
36 * [server].
37 */
38 typedef RequestHandler RequestHandlerFactory(AnalysisServer server);
39
40 /**
41 * A plugin that defines the extension points and extensions that are inherently
42 * defined by the analysis server.
43 */
44 class ServerPlugin implements Plugin {
45 /**
46 * The simple identifier of the extension point that allows plugins to
47 * register file patterns that will cause files to be analyzed.
48 */
49 static const String ANALYZED_FILE_PATTERNS_EXTENSION_POINT =
50 'analyzedFilePatterns';
51
52 /**
53 * The simple identifier of the extension point that allows plugins to
54 * register assist contributors.
55 */
56 static const String ASSIST_CONTRIBUTOR_EXTENSION_POINT = 'assistContributor';
57
58 /**
59 * The simple identifier of the extension point that allows plugins to
60 * register completion contributors.
61 */
62 static const String COMPLETION_CONTRIBUTOR_EXTENSION_POINT =
63 'completionContributor';
64
65 /**
66 * The simple identifier of the extension point that allows plugins to
67 * register domains.
68 */
69 static const String DOMAIN_EXTENSION_POINT = 'domain';
70
71 /**
72 * The simple identifier of the extension point that allows plugins to
73 * register fix contributors.
74 */
75 static const String FIX_CONTRIBUTOR_EXTENSION_POINT = 'fixContributor';
76
77 /**
78 * The simple identifier of the extension point that allows plugins to
79 * register index contributors.
80 */
81 static const String INDEX_CONTRIBUTOR_EXTENSION_POINT = 'indexContributor';
82
83 /**
84 * The simple identifier of the extension point that allows plugins to
85 * register navigation contributors.
86 */
87 static const String NAVIGATION_CONTRIBUTOR_EXTENSION_POINT =
88 'navigationContributor';
89
90 /**
91 * The simple identifier of the extension point that allows plugins to
92 * register element occurrences.
93 */
94 static const String OCCURRENCES_CONTRIBUTOR_EXTENSION_POINT =
95 'occurrencesContributor';
96
97 /**
98 * The simple identifier of the extension point that allows plugins to
99 * register analysis result listeners.
100 */
101 static const String SET_ANALISYS_DOMAIN_EXTENSION_POINT = 'setAnalysisDomain';
102
103 /**
104 * The unique identifier of this plugin.
105 */
106 static const String UNIQUE_IDENTIFIER = 'analysis_server.core';
107
108 /**
109 * The extension point that allows plugins to register file patterns that will
110 * cause files to be analyzed.
111 */
112 ExtensionPoint<List<String>> analyzedFilePatternsExtensionPoint;
113
114 /**
115 * The extension point that allows plugins to register assist contributors.
116 */
117 ExtensionPoint<AssistContributor> assistContributorExtensionPoint;
118
119 /**
120 * The extension point that allows plugins to register completion
121 * contributors.
122 */
123 ExtensionPoint<CompletionContributorFactory>
124 completionContributorExtensionPoint;
125
126 /**
127 * The extension point that allows plugins to register domains with the
128 * server.
129 */
130 ExtensionPoint<RequestHandlerFactory> domainExtensionPoint;
131
132 /**
133 * The extension point that allows plugins to register fix contributors with
134 * the server.
135 */
136 ExtensionPoint<FixContributor> fixContributorExtensionPoint;
137
138 /**
139 * The extension point that allows plugins to register navigation
140 * contributors.
141 */
142 ExtensionPoint<NavigationContributor> navigationContributorExtensionPoint;
143
144 /**
145 * The extension point that allows plugins to register occurrences
146 * contributors.
147 */
148 ExtensionPoint<OccurrencesContributor> occurrencesContributorExtensionPoint;
149
150 /**
151 * The extension point that allows plugins to get access to the `analysis`
152 * domain.
153 */
154 ExtensionPoint<SetAnalysisDomain> setAnalysisDomainExtensionPoint;
155
156 /**
157 * Initialize a newly created plugin.
158 */
159 ServerPlugin();
160
161 /**
162 * Return a list containing all of the file patterns that can cause files to
163 * be analyzed.
164 */
165 List<String> get analyzedFilePatterns {
166 List<String> patterns = <String>[];
167 for (List<String> extension
168 in analyzedFilePatternsExtensionPoint.extensions) {
169 patterns.addAll(extension);
170 }
171 return patterns;
172 }
173
174 /**
175 * Return a list containing all of the assist contributors that were
176 * contributed.
177 */
178 List<AssistContributor> get assistContributors =>
179 assistContributorExtensionPoint.extensions;
180
181 /**
182 * Return a list containing all of the completion contributors that were
183 * contributed.
184 */
185 Iterable<CompletionContributor> get completionContributors =>
186 completionContributorExtensionPoint.extensions
187 .map((CompletionContributorFactory factory) => factory());
188
189 /**
190 * Return a list containing all of the fix contributors that were contributed.
191 */
192 List<FixContributor> get fixContributors =>
193 fixContributorExtensionPoint.extensions;
194
195 /**
196 * Return a list containing all of the navigation contributors that were
197 * contributed.
198 */
199 List<NavigationContributor> get navigationContributors =>
200 navigationContributorExtensionPoint.extensions;
201
202 /**
203 * Return a list containing all of the occurrences contributors that were
204 * contributed.
205 */
206 List<OccurrencesContributor> get occurrencesContributors =>
207 occurrencesContributorExtensionPoint.extensions;
208
209 /**
210 * Return a list containing all of the receivers of the `analysis` domain
211 * instance.
212 */
213 List<SetAnalysisDomain> get setAnalysisDomainFunctions =>
214 setAnalysisDomainExtensionPoint.extensions;
215
216 @override
217 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
218
219 /**
220 * Use the given [server] to create all of the domains ([RequestHandler]'s)
221 * that have been registered and return the newly created domains.
222 */
223 List<RequestHandler> createDomains(AnalysisServer server) {
224 if (domainExtensionPoint == null) {
225 return <RequestHandler>[];
226 }
227 return domainExtensionPoint.extensions
228 .map((RequestHandlerFactory factory) => factory(server))
229 .toList();
230 }
231
232 @override
233 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
234 analyzedFilePatternsExtensionPoint = new ExtensionPoint<List<String>>(
235 this, ANALYZED_FILE_PATTERNS_EXTENSION_POINT, null);
236 registerExtensionPoint(analyzedFilePatternsExtensionPoint);
237 assistContributorExtensionPoint = new ExtensionPoint<AssistContributor>(
238 this, ASSIST_CONTRIBUTOR_EXTENSION_POINT, null);
239 registerExtensionPoint(assistContributorExtensionPoint);
240 completionContributorExtensionPoint =
241 new ExtensionPoint<CompletionContributorFactory>(
242 this, COMPLETION_CONTRIBUTOR_EXTENSION_POINT, null);
243 registerExtensionPoint(completionContributorExtensionPoint);
244 domainExtensionPoint = new ExtensionPoint<RequestHandlerFactory>(
245 this, DOMAIN_EXTENSION_POINT, null);
246 registerExtensionPoint(domainExtensionPoint);
247 fixContributorExtensionPoint = new ExtensionPoint<FixContributor>(
248 this, FIX_CONTRIBUTOR_EXTENSION_POINT, null);
249 registerExtensionPoint(fixContributorExtensionPoint);
250 navigationContributorExtensionPoint =
251 new ExtensionPoint<NavigationContributor>(
252 this, NAVIGATION_CONTRIBUTOR_EXTENSION_POINT, null);
253 registerExtensionPoint(navigationContributorExtensionPoint);
254 occurrencesContributorExtensionPoint =
255 new ExtensionPoint<OccurrencesContributor>(
256 this, OCCURRENCES_CONTRIBUTOR_EXTENSION_POINT, null);
257 registerExtensionPoint(occurrencesContributorExtensionPoint);
258 setAnalysisDomainExtensionPoint = new ExtensionPoint<SetAnalysisDomain>(
259 this, SET_ANALISYS_DOMAIN_EXTENSION_POINT, null);
260 registerExtensionPoint(setAnalysisDomainExtensionPoint);
261 }
262
263 @override
264 void registerExtensions(RegisterExtension registerExtension) {
265 //
266 // Register analyzed file patterns.
267 //
268 List<String> patterns = <String>[
269 '**/*.${AnalysisEngine.SUFFIX_DART}',
270 '**/*.${AnalysisEngine.SUFFIX_HTML}',
271 '**/*.${AnalysisEngine.SUFFIX_HTM}',
272 '**/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}',
273 '**/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'
274 ];
275 registerExtension(ANALYZED_FILE_PATTERNS_EXTENSION_POINT_ID, patterns);
276 //
277 // Register assist contributors.
278 //
279 registerExtension(
280 ASSIST_CONTRIBUTOR_EXTENSION_POINT_ID, new DefaultAssistContributor());
281 //
282 // Register completion contributors.
283 //
284 // TODO(brianwilkerson) Register the completion contributors.
285 //registerExtension(COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, ???);
286 //
287 // Register analysis contributors.
288 //
289 registerExtension(NAVIGATION_CONTRIBUTOR_EXTENSION_POINT_ID,
290 new DartNavigationComputer());
291 registerExtension(OCCURRENCES_CONTRIBUTOR_EXTENSION_POINT_ID,
292 new DartOccurrencesComputer());
293 //
294 // Register domains.
295 //
296 String domainId = Plugin.join(UNIQUE_IDENTIFIER, DOMAIN_EXTENSION_POINT);
297 registerExtension(
298 domainId, (AnalysisServer server) => new ServerDomainHandler(server));
299 registerExtension(
300 domainId, (AnalysisServer server) => new AnalysisDomainHandler(server));
301 registerExtension(
302 domainId, (AnalysisServer server) => new EditDomainHandler(server));
303 registerExtension(
304 domainId, (AnalysisServer server) => new SearchDomainHandler(server));
305 registerExtension(domainId,
306 (AnalysisServer server) => new CompletionDomainHandler(server));
307 registerExtension(domainId,
308 (AnalysisServer server) => new ExecutionDomainHandler(server));
309 registerExtension(domainId,
310 (AnalysisServer server) => new DiagnosticDomainHandler(server));
311 registerExtension(domainId,
312 (AnalysisServer server) => new AnalyticsDomainHandler(server));
313 registerExtension(
314 domainId, (AnalysisServer server) => new KytheDomainHandler(server));
315
316 //
317 // Register fix contributors.
318 //
319 registerExtension(
320 FIX_CONTRIBUTOR_EXTENSION_POINT_ID, new DefaultFixContributor());
321 }
322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698