| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 analysis_server.src.provisional.completion.dart.plugin; | 5 library analysis_server.src.provisional.completion.dart.plugin; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/provisional/completion/completion.dart'; | 7 import 'package:analysis_server/src/provisional/completion/completion.dart'; |
| 8 import 'package:analysis_server/src/provisional/completion/dart/completion.dart'
; | 8 import 'package:analysis_server/src/provisional/completion/dart/completion.dart'
; |
| 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 10 import 'package:analysis_server/src/services/completion/dart/arglist_contributor
.dart'; | 10 import 'package:analysis_server/src/services/completion/dart/arglist_contributor
.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * The unique identifier of this plugin. | 45 * The unique identifier of this plugin. |
| 46 */ | 46 */ |
| 47 static const String UNIQUE_IDENTIFIER = 'dart.completion'; | 47 static const String UNIQUE_IDENTIFIER = 'dart.completion'; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The extension point that allows plugins to register Dart specific | 50 * The extension point that allows plugins to register Dart specific |
| 51 * completion contributor factories. | 51 * completion contributor factories. |
| 52 */ | 52 */ |
| 53 ExtensionPoint _contributorExtensionPoint; | 53 ExtensionPoint<DartCompletionContributorFactory> _contributorExtensionPoint; |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Return a list containing all of the Dart specific completion contributors. | 56 * Return a list containing all of the Dart specific completion contributors. |
| 57 */ | 57 */ |
| 58 Iterable<DartCompletionContributor> get contributors => | 58 Iterable<DartCompletionContributor> get contributors => |
| 59 _contributorExtensionPoint.extensions.map( | 59 _contributorExtensionPoint.extensions.map( |
| 60 (Object factory) => (factory as DartCompletionContributorFactory)()); | 60 (Object factory) => (factory as DartCompletionContributorFactory)()); |
| 61 | 61 |
| 62 @override | 62 @override |
| 63 String get uniqueIdentifier => UNIQUE_IDENTIFIER; | 63 String get uniqueIdentifier => UNIQUE_IDENTIFIER; |
| 64 | 64 |
| 65 @override | 65 @override |
| 66 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { | 66 void registerExtensionPoints(RegisterExtensionPoint registerExtensionPoint) { |
| 67 _contributorExtensionPoint = registerExtensionPoint( | 67 _contributorExtensionPoint = |
| 68 CONTRIBUTOR_EXTENSION_POINT, | 68 new ExtensionPoint<DartCompletionContributorFactory>( |
| 69 _validateDartCompletionContributorExtension); | 69 this, CONTRIBUTOR_EXTENSION_POINT, null); |
| 70 registerExtensionPoint(_contributorExtensionPoint); |
| 70 } | 71 } |
| 71 | 72 |
| 72 @override | 73 @override |
| 73 void registerExtensions(RegisterExtension registerExtension) { | 74 void registerExtensions(RegisterExtension registerExtension) { |
| 74 // | 75 // |
| 75 // Register DartCompletionManager as a CompletionContributor | 76 // Register DartCompletionManager as a CompletionContributor |
| 76 // which delegates to all the DartCompletionContributors | 77 // which delegates to all the DartCompletionContributors |
| 77 // | 78 // |
| 78 registerExtension(COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, | 79 registerExtension(COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 79 () => new DartCompletionManager()); | 80 () => new DartCompletionManager()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // () => new OverrideContributor()); | 113 // () => new OverrideContributor()); |
| 113 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, | 114 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 114 () => new StaticMemberContributor()); | 115 () => new StaticMemberContributor()); |
| 115 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, | 116 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 116 () => new TypeMemberContributor()); | 117 () => new TypeMemberContributor()); |
| 117 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, | 118 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 118 () => new UriContributor()); | 119 () => new UriContributor()); |
| 119 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, | 120 registerExtension(DART_COMPLETION_CONTRIBUTOR_EXTENSION_POINT_ID, |
| 120 () => new VariableNameContributor()); | 121 () => new VariableNameContributor()); |
| 121 } | 122 } |
| 122 | |
| 123 /** | |
| 124 * Validate the given extension by throwing an [ExtensionError] if it is not a | |
| 125 * valid Dart specific completion contributor. | |
| 126 */ | |
| 127 void _validateDartCompletionContributorExtension(Object extension) { | |
| 128 if (extension is! DartCompletionContributorFactory) { | |
| 129 String id = _contributorExtensionPoint.uniqueIdentifier; | |
| 130 throw new ExtensionError( | |
| 131 'Extensions to $id must be a DartCompletionContributorFactory'); | |
| 132 } | |
| 133 } | |
| 134 } | 123 } |
| OLD | NEW |