diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 4e4c8aad6fe..fc27b58e63a 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -12,6 +12,7 @@ import {IFilter} from 'vs/base/common/filters'; import {IMarker} from 'vs/platform/markers/common/markers'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {ModeTransition} from 'vs/editor/common/core/modeTransition'; +import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegistry'; export interface ITokenizationResult { type?:string; @@ -756,3 +757,7 @@ export interface IRichEditSupport { */ brackets?: IRichEditBrackets; } + +// --- feature registries ------ + +export const ReferenceSearchRegistry = new LanguageFeatureRegistry('referenceSupport'); diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index f19b5054cfd..fbca5cc4bc5 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts @@ -25,11 +25,11 @@ import {EditorAction} from 'vs/editor/common/editorAction'; import {Behaviour} from 'vs/editor/common/editorActionEnablement'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions'; -import {IReference} from 'vs/editor/common/modes'; +import {IReference, ReferenceSearchRegistry} from 'vs/editor/common/modes'; import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions'; import {Events, IPeekViewService, getOuterEditor} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; -import {ReferenceRegistry, findReferences} from '../common/referenceSearch'; +import {findReferences} from '../common/referenceSearch'; import {EventType, ReferencesModel} from './referenceSearchModel'; import {ReferenceWidget} from './referenceSearchWidget'; @@ -267,7 +267,7 @@ export class ReferenceAction extends EditorAction { } public isSupported():boolean { - return ReferenceRegistry.has(this.editor.getModel()) && super.isSupported(); + return ReferenceSearchRegistry.has(this.editor.getModel()) && super.isSupported(); } public getEnablementState():boolean { @@ -280,7 +280,7 @@ export class ReferenceAction extends EditorAction { let context = model.getLineContext(position.lineNumber); let offset = position.column - 1; - return ReferenceRegistry.all(model).some(support => { + return ReferenceSearchRegistry.all(model).some(support => { return support.canFindReferences(context, offset); }); } diff --git a/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts index 7eb21d1de37..c43b7f9117a 100644 --- a/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts @@ -9,15 +9,12 @@ import {onUnexpectedError} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; import {IModel, IPosition} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; -import {IReference, IReferenceSupport} from 'vs/editor/common/modes'; -import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegistry'; - -export const ReferenceRegistry = new LanguageFeatureRegistry('referenceSupport'); +import {IReference, ReferenceSearchRegistry} from 'vs/editor/common/modes'; export function findReferences(model: IModel, position: IPosition): TPromise { // collect references from all providers - const promises = ReferenceRegistry.ordered(model).map(provider => { + const promises = ReferenceSearchRegistry.ordered(model).map(provider => { return provider.findReferences(model.getAssociatedResource(), position, true).then(result => { if (Array.isArray(result)) { return result; diff --git a/src/vs/languages/typescript/common/languageFeatures.ts b/src/vs/languages/typescript/common/languageFeatures.ts index d877a51294e..61c22f8cfc9 100644 --- a/src/vs/languages/typescript/common/languageFeatures.ts +++ b/src/vs/languages/typescript/common/languageFeatures.ts @@ -17,7 +17,6 @@ import {SuggestRegistry} from 'vs/editor/contrib/suggest/common/suggest'; import {ParameterHintsRegistry} from 'vs/editor/contrib/parameterHints/common/parameterHints'; import {OccurrencesRegistry} from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter'; import {ExtraInfoRegistry} from 'vs/editor/contrib/hover/common/hover'; -import {ReferenceRegistry} from 'vs/editor/contrib/referenceSearch/common/referenceSearch'; import {DeclarationRegistry} from 'vs/editor/contrib/goToDeclaration/common/goToDeclaration'; import {OutlineRegistry} from 'vs/editor/contrib/quickOpen/common/quickOpen'; import {FormatRegistry, FormatOnTypeRegistry} from 'vs/editor/contrib/format/common/format'; @@ -33,7 +32,7 @@ export function register(modelService: IModelService, markerService: IMarkerServ disposables.push(ExtraInfoRegistry.register(selector, new QuickInfoAdapter(modelService, worker))); disposables.push(OccurrencesRegistry.register(selector, new OccurrencesAdapter(modelService, worker))); disposables.push(DeclarationRegistry.register(selector, new DeclarationAdapter(modelService, worker))); - disposables.push(ReferenceRegistry.register(selector, new ReferenceAdapter(modelService, worker))); + disposables.push(modes.ReferenceSearchRegistry.register(selector, new ReferenceAdapter(modelService, worker))); disposables.push(OutlineRegistry.register(selector, new OutlineAdapter(modelService, worker))); disposables.push(FormatRegistry.register(selector, new FormatAdapter(modelService, worker))); disposables.push(FormatOnTypeRegistry.register(selector, new FormatAdapter(modelService, worker))); diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 3ff734f3d51..7a656403090 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -19,7 +19,6 @@ import {ExtHostDiagnostics} from 'vs/workbench/api/node/extHostDiagnostics'; import {DeclarationRegistry} from 'vs/editor/contrib/goToDeclaration/common/goToDeclaration'; import {ExtraInfoRegistry} from 'vs/editor/contrib/hover/common/hover'; import {OccurrencesRegistry} from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter'; -import {ReferenceRegistry} from 'vs/editor/contrib/referenceSearch/common/referenceSearch'; import {QuickFixRegistry} from 'vs/editor/contrib/quickFix/common/quickFix'; import {OutlineRegistry, IOutlineEntry, IOutlineSupport} from 'vs/editor/contrib/quickOpen/common/quickOpen'; import {NavigateTypesSupportRegistry, INavigateTypesSupport, ITypeBearing} from 'vs/workbench/parts/search/common/search'; @@ -942,7 +941,7 @@ export class MainThreadLanguageFeatures { // --- references $registerReferenceSupport(handle: number, selector: vscode.DocumentSelector): TPromise { - this._registrations[handle] = ReferenceRegistry.register(selector, { + this._registrations[handle] = modes.ReferenceSearchRegistry.register(selector, { canFindReferences() { return true; },