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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/provisional/completion/dart/completion_plugin.dart
diff --git a/pkg/analysis_server/lib/src/provisional/completion/dart/completion_plugin.dart b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_plugin.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7a21bbb66137fd30b655964c0d14f6330265405b
--- /dev/null
+++ b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_plugin.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library analysis_server.src.provisional.completion.dart.plugin;
+
+import 'package:analysis_server/src/provisional/completion/dart/completion.dart';
+import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
+import 'package:analysis_server/src/services/completion/dart/keyword_contributor.dart';
+import 'package:plugin/plugin.dart';
+
+/**
+ * The shared dart completion plugin instance.
+ */
+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
+
+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
+ /**
+ * The simple identifier of the extension point that allows plugins to
+ * register Dart specific completion contributor factories.
+ * Use [DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID]
+ * when registering contributors.
+ */
+ static const String CONTRIBUTOR_EXTENSION_POINT = 'contributor';
+
+ /**
+ * The unique identifier of this plugin.
+ */
+ static const String UNIQUE_IDENTIFIER = 'dart.completion';
+
+ /**
+ * The extension point that allows plugins to register Dart specific
+ * completion contributor factories.
+ */
+ ExtensionPoint _contributorExtensionPoint;
+
+ @override
+ String get uniqueIdentifier => UNIQUE_IDENTIFIER;
+
+ /**
+ * Return a list containing all of the Dart specific completion contributor
+ * factories that were contributed.
+ */
+ List<DartCompletionContributorFactory> get contributorFactories =>
+ _contributorExtensionPoint.extensions;
+
+ @override
+ void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) {
+ _contributorExtensionPoint = registerExtensionPoint(
+ CONTRIBUTOR_EXTENSION_POINT,
+ _validateDartCompletionContributorExtension);
+ }
+
+ @override
+ void registerExtensions(RegisterExtension registerExtension) {
+ registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID,
+ () => new KeywordContributor());
+ }
+
+ /**
+ * Validate the given extension by throwing an [ExtensionError] if it is not a
+ * valid Dart specific completion contributor.
+ */
+ void _validateDartCompletionContributorExtension(Object extension) {
+ if (extension is! DartCompletionContributorFactory) {
+ String id = _contributorExtensionPoint.uniqueIdentifier;
+ throw new ExtensionError(
+ 'Extensions to $id must be a DartCompletionContributorFactory');
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698