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


TypeScript CodeActionProviderRegistry.all方法代码示例

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


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

示例1: getCodeActions

export function getCodeActions(model: IReadOnlyModel, range: Range): TPromise<IQuickFix2[]> {

	const quickFixes: IQuickFix2[] = [];
	let ids = new IdGenerator('quickfix');
	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise((token) => {
			return support.provideCodeActions(model, range, token);
		}).then(result => {
			if (!Array.isArray(result)) {
				return;
			}
			for (let fix of result) {
				quickFixes.push({
					command: fix.command,
					score: fix.score,
					id: ids.nextId(),
					support
				});
			}
		}, err => {
			onUnexpectedError(err);
		});
	});

	return TPromise.join(promises).then(() => quickFixes);
}
开发者ID:CPoirot3,项目名称:vscode,代码行数:26,代码来源:quickFix.ts

示例2: getCodeActions

export function getCodeActions(model: ITextModel, range: Range, filter?: CodeActionFilter): TPromise<CodeAction[]> {

	const allResults: CodeAction[] = [];
	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, range, { only: filter && filter.kind ? filter.kind.value : undefined }, token)).then(result => {
			if (Array.isArray(result)) {
				for (const quickFix of result) {
					if (!quickFix) {
						continue;
					}

					if (!filter || !filter.kind || (quickFix.kind && filter.kind.contains(quickFix.kind))) {
						if (quickFix.kind && CodeActionKind.Source.contains(quickFix.kind) && (!filter || !filter.includeSourceActions)) {
							continue;
						}
						allResults.push(quickFix);
					}
				}
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(
		() => mergeSort(allResults, codeActionsComparator)
	);
}
开发者ID:costincaraivan,项目名称:vscode,代码行数:28,代码来源:quickFix.ts

示例3: getCodeActions

export function getCodeActions(model: ITextModel, rangeOrSelection: Range | Selection, trigger?: CodeActionTrigger, token: CancellationToken = CancellationToken.None): Promise<CodeAction[]> {
	const codeActionContext: CodeActionContext = {
		only: trigger && trigger.filter && trigger.filter.kind ? trigger.filter.kind.value : undefined,
		trigger: trigger && trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
	};

	const promises = CodeActionProviderRegistry.all(model)
		.filter(provider => {
			// Avoid calling providers that we know will not return code actions of interest
			return !provider.providedCodeActionKinds || provider.providedCodeActionKinds.some(providedKind => isValidActionKind(trigger && trigger.filter, providedKind));
		})
		.map(support => {
			return Promise.resolve(support.provideCodeActions(model, rangeOrSelection, codeActionContext, token)).then(providedCodeActions => {
				if (!Array.isArray(providedCodeActions)) {
					return [];
				}
				return providedCodeActions.filter(action => isValidAction(trigger && trigger.filter, action));
			}, (err): CodeAction[] => {
				if (isPromiseCanceledError(err)) {
					throw err;
				}

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

	return Promise.all(promises)
		.then(flatten)
		.then(allCodeActions => mergeSort(allCodeActions, codeActionsComparator));
}
开发者ID:ramesius,项目名称:vscode,代码行数:31,代码来源:codeAction.ts

示例4: getCodeActions

export function getCodeActions(model: ITextModel, rangeOrSelection: Range | Selection, trigger?: CodeActionTrigger): TPromise<CodeAction[]> {
	const codeActionContext: CodeActionContext = {
		only: trigger && trigger.filter && trigger.filter.kind ? trigger.filter.kind.value : undefined,
		trigger: trigger && trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
	};

	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, rangeOrSelection, codeActionContext, token)).then(providedCodeActions => {
			if (!Array.isArray(providedCodeActions)) {
				return [];
			}
			return providedCodeActions.filter(action => isValidAction(trigger && trigger.filter, action));
		}, (err): CodeAction[] => {
			if (isPromiseCanceledError(err)) {
				throw err;
			}

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

	return TPromise.join(promises)
		.then(flatten)
		.then(allCodeActions => mergeSort(allCodeActions, codeActionsComparator));
}
开发者ID:jinlongchen2018,项目名称:vscode,代码行数:26,代码来源:codeAction.ts

示例5: getCodeActions

export function getCodeActions(
	model: ITextModel,
	rangeOrSelection: Range | Selection,
	trigger?: CodeActionTrigger,
	token: CancellationToken = CancellationToken.None
): Promise<CodeAction[]> {
	const codeActionContext: CodeActionContext = {
		only: trigger && trigger.filter && trigger.filter.kind ? trigger.filter.kind.value : undefined,
		trigger: trigger && trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
	};

	const promises = CodeActionProviderRegistry.all(model)
		.filter(provider => {
			if (!provider.providedCodeActionKinds) {
				return true;
			}

			// Avoid calling providers that we know will not return code actions of interest
			return provider.providedCodeActionKinds.some(providedKind => {
				// Filter out actions by kind
				// The provided kind can be either a subset of a superset of the filtered kind
				if (trigger && trigger.filter && trigger.filter.kind && !(trigger.filter.kind.contains(providedKind) || new CodeActionKind(providedKind).contains(trigger.filter.kind.value))) {
					return false;
				}

				// Don't return source actions unless they are explicitly requested
				if (trigger && CodeActionKind.Source.contains(providedKind) && (!trigger.filter || !trigger.filter.includeSourceActions)) {
					return false;
				}

				return true;
			});
		})
		.map(support => {
			return Promise.resolve(support.provideCodeActions(model, rangeOrSelection, codeActionContext, token)).then(providedCodeActions => {
				if (!Array.isArray(providedCodeActions)) {
					return [];
				}
				return providedCodeActions.filter(action => isValidAction(trigger && trigger.filter, action));
			}, (err): CodeAction[] => {
				if (isPromiseCanceledError(err)) {
					throw err;
				}

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

	return Promise.all(promises)
		.then(flatten)
		.then(allCodeActions => mergeSort(allCodeActions, codeActionsComparator));
}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:53,代码来源:codeAction.ts

示例6: getCodeActionProviders

function getCodeActionProviders(
	model: ITextModel,
	filter: CodeActionFilter
) {
	return CodeActionProviderRegistry.all(model)
		// Don't include providers that we know will not return code actions of interest
		.filter(provider => {
			if (!provider.providedCodeActionKinds) {
				// We don't know what type of actions this provider will return.
				return true;
			}
			return provider.providedCodeActionKinds.some(kind => mayIncludeActionsOfKind(filter, new CodeActionKind(kind)));
		});
}
开发者ID:eamodio,项目名称:vscode,代码行数:14,代码来源:codeAction.ts

示例7: getCodeActions

export function getCodeActions(model: IReadOnlyModel, range: Range): TPromise<CodeAction[]> {

	const allResults: CodeAction[] = [];
	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, range, token)).then(result => {
			if (Array.isArray(result)) {
				allResults.push(...result);
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(() => allResults);
}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:15,代码来源:quickFix.ts

示例8: getCodeActions

export function getCodeActions(model: ITextModel, range: Range, filter?: CodeActionFilter): TPromise<CodeAction[]> {
	const codeActionContext = { only: filter && filter.kind ? filter.kind.value : undefined };

	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, range, codeActionContext, token)).then(providedCodeActions => {
			if (!Array.isArray(providedCodeActions)) {
				return [];
			}
			return providedCodeActions.filter(action => isValidAction(filter, action));
		}, (err): CodeAction[] => {
			onUnexpectedExternalError(err);
			return [];
		});
	});

	return TPromise.join(promises)
		.then(flatten)
		.then(allCodeActions => mergeSort(allCodeActions, codeActionsComparator));
}
开发者ID:AllureFer,项目名称:vscode,代码行数:19,代码来源:codeAction.ts

示例9: getCodeActions

export function getCodeActions(model: ITextModel, range: Range): TPromise<CodeAction[]> {

	const allResults: CodeAction[] = [];
	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, range, token)).then(result => {
			if (Array.isArray(result)) {
				for (const quickFix of result) {
					if (quickFix) {
						allResults.push(quickFix);
					}
				}
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(
		() => allResults.sort(codeActionsComparator)
	);
}
开发者ID:servicesgpr,项目名称:vscode,代码行数:21,代码来源:quickFix.ts

示例10: getCodeActions

export function getCodeActions(model: ITextModel, range: Range, scope?: CodeActionKind): TPromise<CodeAction[]> {

	const allResults: CodeAction[] = [];
	const promises = CodeActionProviderRegistry.all(model).map(support => {
		return asWinJsPromise(token => support.provideCodeActions(model, range, { only: scope ? scope.value : undefined }, token)).then(result => {
			if (Array.isArray(result)) {
				for (const quickFix of result) {
					if (quickFix) {
						if (!scope || (quickFix.kind && scope.contains(quickFix.kind))) {
							allResults.push(quickFix);
						}
					}
				}
			}
		}, err => {
			onUnexpectedExternalError(err);
		});
	});

	return TPromise.join(promises).then(
		() => mergeSort(allResults, codeActionsComparator)
	);
}
开发者ID:sameer-coder,项目名称:vscode,代码行数:23,代码来源:quickFix.ts


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