當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript async.sequence函數代碼示例

本文整理匯總了TypeScript中vs/base/common/async.sequence函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript sequence函數的具體用法?TypeScript sequence怎麽用?TypeScript sequence使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sequence函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: revealResourcesInOS

function revealResourcesInOS(resources: URI[], windowsService: IWindowsService, notificationService: INotificationService): void {
	if (resources.length) {
		sequence(resources.map(r => () => windowsService.showItemInFolder(paths.normalize(r.fsPath, true))));
	} else {
		notificationService.info(nls.localize('openFileToReveal', "Open a file first to reveal"));
	}
}
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:7,代碼來源:fileCommands.ts

示例2: provideSuggestionItems

export function provideSuggestionItems(model: IReadOnlyModel, position: Position, options: ISuggestOptions = {}): TPromise<ISuggestionItem[]> {

	const result: ISuggestionItem[] = [];
	const suggestFilter = createSuggesionFilter(options);
	const suggestCompare = createSuggesionComparator(options);

	// add suggestions from snippet registry
	const snippets = SnippetsRegistry.getSnippets(model, position);
	fillInSuggestResult(result, snippets, undefined, suggestFilter);


	// add suggestions from contributed providers - providers are ordered in groups of
	// equal score and once a group produces a result the process stops
	let hasResult = false;
	const factory = (options.groups || SuggestRegistry.orderedGroups(model)).map(supports => {
		return () => {
			// stop when we have a result
			if (hasResult) {
				return;
			}
			// for each support in the group ask for suggestions
			return TPromise.join(supports.map(support => asWinJsPromise(token => support.provideCompletionItems(model, position, token)).then(values => {
				if (!isFalsyOrEmpty(values)) {
					for (let suggestResult of values) {
						hasResult = fillInSuggestResult(result, suggestResult, support, suggestFilter) || hasResult;
					}
				}
			}, onUnexpectedError)));
		};
	});

	return sequence(factory).then(() => result.sort(suggestCompare));
}
開發者ID:ChristianAlexander,項目名稱:vscode,代碼行數:33,代碼來源:suggest.ts

示例3: revealResourcesInOS

function revealResourcesInOS(resources: URI[], windowsService: IWindowsService, messageService: IMessageService): void {
	if (resources.length) {
		sequence(resources.map(r => () => windowsService.showItemInFolder(paths.normalize(r.fsPath, true))));
	} else {
		messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal"));
	}
}
開發者ID:tonycleveland,項目名稱:vscode,代碼行數:7,代碼來源:fileCommands.ts

示例4: provideSuggestionItems

export function provideSuggestionItems(model: IReadOnlyModel, position: Position, snippetConfig: SnippetConfig = 'bottom', onlyFrom?: ISuggestSupport[]): TPromise<ISuggestionItem[]> {

	const result: ISuggestionItem[] = [];
	const acceptSuggestion = createSuggesionFilter(snippetConfig);

	position = position.clone();

	// get provider groups, always add snippet suggestion provider
	const supports = SuggestRegistry.orderedGroups(model);
	supports.unshift([snippetSuggestSupport]);

	// add suggestions from contributed providers - providers are ordered in groups of
	// equal score and once a group produces a result the process stops
	let hasResult = false;
	const factory = supports.map(supports => {
		return () => {
			// stop when we have a result
			if (hasResult) {
				return;
			}
			// for each support in the group ask for suggestions
			return TPromise.join(supports.map(support => {

				if (!isFalsyOrEmpty(onlyFrom) && onlyFrom.indexOf(support) < 0) {
					return;
				}

				return asWinJsPromise(token => support.provideCompletionItems(model, position, token)).then(container => {

					const len = result.length;

					if (container && !isFalsyOrEmpty(container.suggestions)) {
						for (let suggestion of container.suggestions) {
							if (acceptSuggestion(suggestion)) {

								fixOverwriteBeforeAfter(suggestion, container);

								result.push({
									position,
									container,
									suggestion,
									support,
									resolve: createSuggestionResolver(support, suggestion, model, position)
								});
							}
						}
					}

					if (len !== result.length && support !== snippetSuggestSupport) {
						hasResult = true;
					}

				}, onUnexpectedError);
			}));
		};
	});

	return sequence(factory).then(() => result.sort(getSuggestionComparator(snippetConfig)));
}
開發者ID:elemongw,項目名稱:vscode,代碼行數:59,代碼來源:suggest.ts

示例5: revealResourcesInOS

function revealResourcesInOS(resources: URI[], windowsService: IWindowsService, notificationService: INotificationService, workspaceContextService: IWorkspaceContextService): void {
	if (resources.length) {
		sequence(resources.map(r => () => windowsService.showItemInFolder(r)));
	} else if (workspaceContextService.getWorkspace().folders.length) {
		windowsService.showItemInFolder(workspaceContextService.getWorkspace().folders[0].uri);
	} else {
		notificationService.info(nls.localize('openFileToReveal', "Open a file first to reveal"));
	}
}
開發者ID:joelday,項目名稱:vscode,代碼行數:9,代碼來源:fileCommands.ts

示例6: getMultiSelectedResources

const revealInOSHandler = (accessor: ServicesAccessor, resource: URI) => {
	// Without resource, try to look at the active editor
	const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));

	if (resources.length) {
		const windowsService = accessor.get(IWindowsService);
		sequence(resources.map(r => () => windowsService.showItemInFolder(paths.normalize(r.fsPath, true))));
	} else {
		const messageService = accessor.get(IMessageService);
		messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal"));
	}
};
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:12,代碼來源:fileCommands.ts

示例7: provideCompletionItems

export function provideCompletionItems(model: IReadOnlyModel, position: IEditorPosition, groups?: ISuggestSupport[][]): TPromise<ISuggestResult2[]> {

	if (!groups) {
		groups = SuggestRegistry.orderedGroups(model);
	}

	const result: ISuggestResult2[] = [];

	const factory = groups.map((supports, index) => {
		return () => {

			// stop as soon as a group produced a result
			if (result.length > 0) {
				return;
			}

			// for each support in the group ask for suggestions
			return TPromise.join(supports.map(support => {
				return asWinJsPromise((token) => {
					return support.provideCompletionItems(model, position, token);
				}).then(values => {

					if (!values) {
						return;
					}

					for (let suggestResult of values) {

						if (!suggestResult || isFalsyOrEmpty(suggestResult.suggestions)) {
							continue;
						}

						result.push({
							support,
							currentWord: suggestResult.currentWord,
							incomplete: suggestResult.incomplete,
							suggestions: suggestResult.suggestions
						});
					}

				}, onUnexpectedError);
			}));
		};
	});

	return sequence(factory).then(() => {
		// add snippets to the first group
		const snippets = SnippetsRegistry.getSnippets(model, position);
		result.push(snippets);
		return result;
	});
}
開發者ID:Buildsoftwaresphere,項目名稱:vscode,代碼行數:52,代碼來源:suggest.ts

示例8: 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;
		}
	});
}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:47,代碼來源:rename.ts

示例9: provideSignatureHelp

export function provideSignatureHelp(model: ITextModel, position: Position): TPromise<SignatureHelp> {

	const supports = SignatureHelpProviderRegistry.ordered(model);
	let result: SignatureHelp;

	return sequence(supports.map(support => () => {

		if (result) {
			// stop when there is a result
			return undefined;
		}

		return asWinJsPromise(token => support.provideSignatureHelp(model, position, token)).then(thisResult => {
			result = thisResult;
		}, onUnexpectedExternalError);

	})).then(() => result);
}
開發者ID:AllureFer,項目名稱:vscode,代碼行數:18,代碼來源:provideSignatureHelp.ts

示例10: getDocumentFormattingEdits

export function getDocumentFormattingEdits(model: IReadOnlyModel, options: FormattingOptions): TPromise<ISingleEditOperation[]> {
	const providers = DocumentFormattingEditProviderRegistry.ordered(model);

	// try range formatters when no document formatter is registered
	if (providers.length === 0) {
		return getDocumentRangeFormattingEdits(model, model.getFullModelRange(), options);
	}

	let result: ISingleEditOperation[];
	return sequence(providers.map(provider => {
		if (isFalsyOrEmpty(result)) {
			return () => {
				return asWinJsPromise(token => provider.provideDocumentFormattingEdits(model, options, token)).then(value => {
					result = value;
				}, onUnexpectedExternalError);
			};
		}
	})).then(() => result);
}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:19,代碼來源:format.ts


注:本文中的vs/base/common/async.sequence函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。