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


TypeScript expand-abbreviation.expand函数代码示例

本文整理汇总了TypeScript中@emmetio/expand-abbreviation.expand函数的典型用法代码示例。如果您正苦于以下问题:TypeScript expand函数的具体用法?TypeScript expand怎么用?TypeScript expand使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getExpandedAbbreviation

	getExpandedAbbreviation(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem {
		if (!vscode.workspace.getConfiguration('emmet')['showExpandedAbbreviation']) {
			return;
		}
		let [rangeToReplace, wordToExpand] = extractAbbreviation(position);
		if (!rangeToReplace || !wordToExpand) {
			return;
		}
		let syntax = getSyntax(document);
		let expandedWord = expand(wordToExpand, {
			field: field,
			syntax: syntax,
			profile: getProfile(syntax),
			addons: syntax === 'jsx' ? { 'jsx': true } : null
		});

		let completionitem = new vscode.CompletionItem(wordToExpand);
		completionitem.insertText = new vscode.SnippetString(expandedWord);
		completionitem.documentation = removeTabStops(expandedWord);
		completionitem.range = rangeToReplace;
		completionitem.detail = 'Expand Emmet Abbreviation';


		return completionitem;
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:25,代码来源:emmetCompletionProvider.ts

示例2: expand

			let completions: vscode.CompletionItem[] = registry.all({ type: 'string' }).map(snippet => {
				let expandedWord = expand(snippet.value, {
					field: field,
					syntax: syntax
				});

				let item = new vscode.CompletionItem(snippet.key);
				item.documentation = removeTabStops(expandedWord);
				item.detail = 'Complete Emmet Abbreviation';
				item.insertText = snippet.key;
				return item;
			});
开发者ID:FabianLauer,项目名称:vscode,代码行数:12,代码来源:emmetCompletionProvider.ts

示例3: expandAbbreviation

export function expandAbbreviation() {
	let editor = vscode.window.activeTextEditor;
	if (!editor) {
		vscode.window.showInformationMessage('No editor is active');
		return;
	}
	let rangeToReplace: vscode.Range = editor.selection;
	let abbr = editor.document.getText(rangeToReplace);
	if (rangeToReplace.isEmpty) {
		[rangeToReplace, abbr] = extractAbbreviation(rangeToReplace.start);
	}
	let syntax = getSyntax(editor.document);
	let options = {
		field: field,
		syntax: syntax,
		profile: getProfile(getSyntax(editor.document)),
		addons: syntax === 'jsx' ? { 'jsx': true } : null
	};

	let expandedText = expand(abbr, options);
	editor.insertSnippet(new vscode.SnippetString(expandedText), rangeToReplace);
}
开发者ID:FabianLauer,项目名称:vscode,代码行数:22,代码来源:abbreviationActions.ts

示例4: expand

	vscode.window.showInputBox({ prompt: 'Enter Abbreviation' }).then(abbr => {
		if (!abbr || !abbr.trim()) { return; }
		let expandedText = expand(abbr, options);
		editor.insertSnippet(new vscode.SnippetString(expandedText), rangeToReplace);
	});
开发者ID:FabianLauer,项目名称:vscode,代码行数:5,代码来源:abbreviationActions.ts


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