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


TypeScript IModel.getAssociatedResource方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/editorCommon.IModel.getAssociatedResource方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IModel.getAssociatedResource方法的具體用法?TypeScript IModel.getAssociatedResource怎麽用?TypeScript IModel.getAssociatedResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/editorCommon.IModel的用法示例。


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

示例1: getDeclarationsAtPosition

export function getDeclarationsAtPosition(model: IModel, position: IPosition): TPromise<IReference[]> {

	const resource = model.getAssociatedResource();
	const provider = DeclarationRegistry.ordered(model);

	// get results
	const promises = provider.map((provider, idx) => {
		return provider.findDeclaration(resource, position).then(result => {
			return result;
		}, err => {
			onUnexpectedError(err);
		});
	});

	return TPromise.join(promises).then(allReferences => {
		let result: IReference[] = [];
		for (let references of allReferences) {
			if (Array.isArray(references)) {
				result.push(...references);
			} else if (references) {
				result.push(references);
			}
		}
		return result;
	});
}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:26,代碼來源:goToDeclaration.ts

示例2: formatRange

export function formatRange(model: IModel, range: IRange, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatRegistry.ordered(model)
		.filter(s => typeof s.formatRange === 'function');

	if (!support) {
		return TPromise.as(undefined);
	}
	return support.formatRange(model.getAssociatedResource(), range, options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:9,代碼來源:format.ts

示例3: getParameterHints

export function getParameterHints(model:IModel, position:IPosition, triggerCharacter: string): TPromise<IParameterHints> {

	let support = ParameterHintsRegistry.ordered(model)[0];
	if (!support) {
		return TPromise.as(undefined);
	}

	return support.getParameterHints(model.getAssociatedResource(), position, triggerCharacter);
}
開發者ID:13572293130,項目名稱:vscode,代碼行數:9,代碼來源:parameterHints.ts

示例4: formatAfterKeystroke

export function formatAfterKeystroke(model: IModel, position: IPosition, ch: string, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatOnTypeRegistry.ordered(model);
	if (!support) {
		return TPromise.as(undefined);
	}
	if (support.autoFormatTriggerCharacters.indexOf(ch) < 0) {
		return TPromise.as(undefined);
	}
	return support.formatAfterKeystroke(model.getAssociatedResource(), position, ch, options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:10,代碼來源:format.ts

示例5:

	let promises = OutlineRegistry.all(model).map(support => {

		return support.getOutline(model.getAssociatedResource()).then(result => {
			if (Array.isArray(result)) {
				entries.push(...result);
			}
		}, err => {
			onUnexpectedError(err);
		});
	});
開發者ID:Newtex,項目名稱:vscode,代碼行數:10,代碼來源:quickOpen.ts

示例6:

	const promises = CodeLensRegistry.all(model).map(support => {
		return support.findCodeLensSymbols(model.getAssociatedResource()).then(result => {
			if (!Array.isArray(result)) {
				return;
			}
			for (let symbol of result) {
				symbols.push({ symbol, support });
			}
		}, err => {
			onUnexpectedError(err);
		});
	});
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:12,代碼來源:codelens.ts

示例7: suggest

export function suggest(model: IModel, position: IPosition, triggerCharacter: string, groups?: ISuggestSupport[][]): TPromise<ISuggestResult2[]> {

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

	const resource = model.getAssociatedResource();
	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 support.suggest(resource, position, triggerCharacter).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:13572293130,項目名稱:vscode,代碼行數:51,代碼來源:suggest.ts

示例8: formatDocument

export function formatDocument(model: IModel, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatRegistry.ordered(model);
	if (!support) {
		return TPromise.as(undefined);
	}
	if (typeof support.formatDocument !== 'function') {
		if (typeof support.formatRange === 'function') {
			return formatRange(model, model.getFullModelRange(), options);
		} else {
			return TPromise.as(undefined);
		}
	}

	return support.formatDocument(model.getAssociatedResource(), options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:15,代碼來源:format.ts

示例9:

	const promises = QuickFixRegistry.all(model).map(support => {
		return support.getQuickFixes(model.getAssociatedResource(), range).then(result => {
			if (!Array.isArray(result)) {
				return;
			}
			for (let fix of result) {
				quickFixes.push({
					command: fix.command,
					score: fix.score,
					id: `quickfix_#${idPool++}`,
					support
				});
			}
		}, err => {
			onUnexpectedError(err);
		});
	});
開發者ID:1424667164,項目名稱:vscode,代碼行數:17,代碼來源:quickFix.ts

示例10:

	let promises = OutlineRegistry.all(model).map(support => {

		if (support.outlineGroupLabel) {
			let keys = Object.keys(support.outlineGroupLabel);
			for (let i = 0, len = keys.length; i < len; i++) {
				let key = keys[i];
				groupLabels[key] = support.outlineGroupLabel[key];
			}
		}

		return support.getOutline(model.getAssociatedResource()).then(result => {
			if (Array.isArray(result)) {
				entries.push(...result);
			}
		}, err => {
			onUnexpectedError(err);
		});
	});
開發者ID:Contagious-Marketing,項目名稱:vscode,代碼行數:18,代碼來源:quickOpen.ts


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