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

Side by Side Diff: pkg/analysis_server/lib/src/provisional/completion/dart/completion_plugin.dart

Issue 1484853002: new DartCompletionPlugin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 library analysis_server.src.provisional.completion.dart.plugin;
6
7 import 'package:analysis_server/src/provisional/completion/dart/completion.dart' ;
8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
9 import 'package:analysis_server/src/services/completion/dart/keyword_contributor .dart';
10 import 'package:plugin/plugin.dart';
11
12 /**
13 * The shared dart completion plugin instance.
14 */
15 final DartCompletionPlugin dartCompletionPlugin = new DartCompletionPlugin();
Brian Wilkerson 2015/11/30 18:10:27 I'm not thrilled about having a global variable, b
danrubel 2015/11/30 18:53:38 The linter plugin does this as well. If we have a
16
17 class DartCompletionPlugin implements Plugin {
Brian Wilkerson 2015/11/30 18:10:27 What's the value of pulling this out to a separate
danrubel 2015/11/30 18:53:38 There will be a top level CompletionContributor ex
Brian Wilkerson 2015/11/30 19:02:01 I assume that will be in the server plugin, in whi
18 /**
19 * The simple identifier of the extension point that allows plugins to
20 * register Dart specific completion contributor factories.
21 * Use [DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID]
22 * when registering contributors.
23 */
24 static const String CONTRIBUTOR_EXTENSION_POINT = 'contributor';
25
26 /**
27 * The unique identifier of this plugin.
28 */
29 static const String UNIQUE_IDENTIFIER = 'dart.completion';
30
31 /**
32 * The extension point that allows plugins to register Dart specific
33 * completion contributor factories.
34 */
35 ExtensionPoint _contributorExtensionPoint;
36
37 @override
38 String get uniqueIdentifier => UNIQUE_IDENTIFIER;
39
40 /**
41 * Return a list containing all of the Dart specific completion contributor
42 * factories that were contributed.
43 */
44 List<DartCompletionContributorFactory> get contributorFactories =>
45 _contributorExtensionPoint.extensions;
46
47 @override
48 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
49 _contributorExtensionPoint = registerExtensionPoint(
50 CONTRIBUTOR_EXTENSION_POINT,
51 _validateDartCompletionContributorExtension);
52 }
53
54 @override
55 void registerExtensions(RegisterExtension registerExtension) {
56 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID,
57 () => new KeywordContributor());
58 }
59
60 /**
61 * Validate the given extension by throwing an [ExtensionError] if it is not a
62 * valid Dart specific completion contributor.
63 */
64 void _validateDartCompletionContributorExtension(Object extension) {
65 if (extension is! DartCompletionContributorFactory) {
66 String id = _contributorExtensionPoint.uniqueIdentifier;
67 throw new ExtensionError(
68 'Extensions to $id must be a DartCompletionContributorFactory');
69 }
70 }
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698