本文整理汇总了TypeScript中vs/editor/common/modes.RenameProviderRegistry类的典型用法代码示例。如果您正苦于以下问题:TypeScript RenameProviderRegistry类的具体用法?TypeScript RenameProviderRegistry怎么用?TypeScript RenameProviderRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenameProviderRegistry类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
editor: ICommonCodeEditor,
contextKeyService: IContextKeyService
) {
super();
this._editor = editor;
this._langId = EditorContextKeys.languageId.bindTo(contextKeyService);
this._hasCompletionItemProvider = EditorContextKeys.hasCompletionItemProvider.bindTo(contextKeyService);
this._hasCodeActionsProvider = EditorContextKeys.hasCodeActionsProvider.bindTo(contextKeyService);
this._hasCodeLensProvider = EditorContextKeys.hasCodeLensProvider.bindTo(contextKeyService);
this._hasDefinitionProvider = EditorContextKeys.hasDefinitionProvider.bindTo(contextKeyService);
this._hasImplementationProvider = EditorContextKeys.hasImplementationProvider.bindTo(contextKeyService);
this._hasTypeDefinitionProvider = EditorContextKeys.hasTypeDefinitionProvider.bindTo(contextKeyService);
this._hasHoverProvider = EditorContextKeys.hasHoverProvider.bindTo(contextKeyService);
this._hasDocumentHighlightProvider = EditorContextKeys.hasDocumentHighlightProvider.bindTo(contextKeyService);
this._hasDocumentSymbolProvider = EditorContextKeys.hasDocumentSymbolProvider.bindTo(contextKeyService);
this._hasReferenceProvider = EditorContextKeys.hasReferenceProvider.bindTo(contextKeyService);
this._hasRenameProvider = EditorContextKeys.hasRenameProvider.bindTo(contextKeyService);
this._hasDocumentFormattingProvider = EditorContextKeys.hasDocumentFormattingProvider.bindTo(contextKeyService);
this._hasDocumentSelectionFormattingProvider = EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(contextKeyService);
this._hasSignatureHelpProvider = EditorContextKeys.hasSignatureHelpProvider.bindTo(contextKeyService);
this._isInWalkThrough = EditorContextKeys.isInEmbeddedEditor.bindTo(contextKeyService);
const update = () => this._update();
// update when model/mode changes
this._register(editor.onDidChangeModel(update));
this._register(editor.onDidChangeModelLanguage(update));
// update when registries change
this._register(modes.SuggestRegistry.onDidChange(update));
this._register(modes.CodeActionProviderRegistry.onDidChange(update));
this._register(modes.CodeLensProviderRegistry.onDidChange(update));
this._register(modes.DefinitionProviderRegistry.onDidChange(update));
this._register(modes.ImplementationProviderRegistry.onDidChange(update));
this._register(modes.TypeDefinitionProviderRegistry.onDidChange(update));
this._register(modes.HoverProviderRegistry.onDidChange(update));
this._register(modes.DocumentHighlightProviderRegistry.onDidChange(update));
this._register(modes.DocumentSymbolProviderRegistry.onDidChange(update));
this._register(modes.ReferenceProviderRegistry.onDidChange(update));
this._register(modes.RenameProviderRegistry.onDidChange(update));
this._register(modes.DocumentFormattingEditProviderRegistry.onDidChange(update));
this._register(modes.DocumentRangeFormattingEditProviderRegistry.onDidChange(update));
this._register(modes.SignatureHelpProviderRegistry.onDidChange(update));
update();
}
示例2: rename
export function rename(model: IReadOnlyModel, position: Position, newName: string): TPromise<WorkspaceEdit> {
const supports = RenameProviderRegistry.ordered(model);
const rejects: string[] = [];
let hasResult = false;
const factory = supports.map(support => {
return () => {
if (!hasResult) {
return asWinJsPromise((token) => {
return support.provideRenameEdits(model, position, newName, token);
}).then(result => {
if (!result) {
// ignore
} else if (!result.rejectReason) {
hasResult = true;
return result;
} else {
rejects.push(result.rejectReason);
}
return undefined;
}, err => {
onUnexpectedExternalError(err);
return TPromise.wrapError<WorkspaceEdit>('provider failed');
});
}
return undefined;
};
});
return sequence(factory).then((values): WorkspaceEdit => {
let result = values[0];
if (rejects.length > 0) {
return {
edits: undefined,
rejectReason: rejects.join('\n')
};
} else if (!result) {
return {
edits: undefined,
rejectReason: localize('no result', "No result.")
};
} else {
return result;
}
});
}
示例3: _update
private _update() {
const model = this._editor.getModel();
if (!model) {
this.reset();
return;
}
this._langId.set(model.getLanguageIdentifier().language);
this._hasCompletionItemProvider.set(modes.SuggestRegistry.has(model));
this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
this._hasDefinitionProvider.set(modes.DefinitionProviderRegistry.has(model));
this._hasImplementationProvider.set(modes.ImplementationProviderRegistry.has(model));
this._hasTypeDefinitionProvider.set(modes.TypeDefinitionProviderRegistry.has(model));
this._hasHoverProvider.set(modes.HoverProviderRegistry.has(model));
this._hasDocumentHighlightProvider.set(modes.DocumentHighlightProviderRegistry.has(model));
this._hasDocumentSymbolProvider.set(modes.DocumentSymbolProviderRegistry.has(model));
this._hasReferenceProvider.set(modes.ReferenceProviderRegistry.has(model));
this._hasRenameProvider.set(modes.RenameProviderRegistry.has(model));
this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._isInWalkThrough.set(model.uri.scheme === Schemas.walkThroughSnippet);
}
示例4: registerRenameProvider
export function registerRenameProvider(languageId: string, provider: modes.RenameProvider): IDisposable {
return modes.RenameProviderRegistry.register(languageId, provider);
}