当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CodeActionProviderRegistry.onDidChange方法代码示例

本文整理汇总了TypeScript中vs/editor/common/modes.CodeActionProviderRegistry.onDidChange方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CodeActionProviderRegistry.onDidChange方法的具体用法?TypeScript CodeActionProviderRegistry.onDidChange怎么用?TypeScript CodeActionProviderRegistry.onDidChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/modes.CodeActionProviderRegistry的用法示例。


在下文中一共展示了CodeActionProviderRegistry.onDidChange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

	constructor(editor: ICodeEditor, markerService: IMarkerService, onAccept: (fix: IQuickFix2, marker:IMarker) => void) {
		super(/*[
			'cancel',
			'loading',
			'empty',
			'suggest',
			'destroy'
		]*/);
		this.editor = editor;
		this.markerService = markerService;
		this.onAccept = onAccept;

		this.quickFixRequestPromise = null;
		this.lightBulpDecoration = [];
		this.toDispose = [];
		this.toLocalDispose = [];

		this.lightBulp = new LightBulpWidget(editor, (pos) => { this.onLightBulpClicked(pos); });

		this.enableAutoQuckFix = false; // turn off for now
		this.autoSuggestDelay = this.editor.getConfiguration().contribInfo.quickSuggestionsDelay;
		if (isNaN(this.autoSuggestDelay) || (!this.autoSuggestDelay && this.autoSuggestDelay !== 0) || this.autoSuggestDelay > 2000 || this.autoSuggestDelay < 0) {
			this.autoSuggestDelay = 300;
		}

		this.toDispose.push(this.editor.onDidChangeModel(() => this.onModelChanged()));
		this.toDispose.push(this.editor.onDidChangeModelMode(() => this.onModelChanged()));
		this.toDispose.push(CodeActionProviderRegistry.onDidChange(this.onModelChanged, this));
	}
开发者ID:1Hgm,项目名称:vscode,代码行数:29,代码来源:quickFixModel.ts

示例2: getCodeActions

export function getCodeActions(
	model: ITextModel,
	rangeOrSelection: Range | Selection,
	trigger: CodeActionTrigger,
	token: CancellationToken
): Promise<CodeActionSet> {
	const filter = trigger.filter || {};

	const codeActionContext: CodeActionContext = {
		only: filter.kind ? filter.kind.value : undefined,
		trigger: trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
	};

	const cts = new TextModelCancellationTokenSource(model, token);
	const providers = getCodeActionProviders(model, filter);

	const disposables = new DisposableStore();
	const promises = providers.map(provider => {
		return Promise.resolve(provider.provideCodeActions(model, rangeOrSelection, codeActionContext, cts.token)).then(providedCodeActions => {
			if (cts.token.isCancellationRequested || !providedCodeActions) {
				return [];
			}
			disposables.add(providedCodeActions);
			return providedCodeActions.actions.filter(action => action && filtersAction(filter, action));
		}, (err): CodeAction[] => {
			if (isPromiseCanceledError(err)) {
				throw err;
			}

			onUnexpectedExternalError(err);
			return [];
		});
	});

	const listener = CodeActionProviderRegistry.onDidChange(() => {
		const newProviders = CodeActionProviderRegistry.all(model);
		if (!equals(newProviders, providers)) {
			cts.cancel();
		}
	});

	return Promise.all(promises)
		.then(flatten)
		.then(actions => new ManagedCodeActionSet(actions, disposables))
		.finally(() => {
			listener.dispose();
			cts.dispose();
		});
}
开发者ID:PKRoma,项目名称:vscode,代码行数:49,代码来源:codeAction.ts

示例3: 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();
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:48,代码来源:editorModeContext.ts


注:本文中的vs/editor/common/modes.CodeActionProviderRegistry.onDidChange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。