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


TypeScript LanguageService.getFoldingRanges方法代码示例

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


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

示例1: getHTMLMode

export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace: Workspace): LanguageMode {
	let htmlDocuments = getLanguageModelCache<HTMLDocument>(10, 60, document => htmlLanguageService.parseHTMLDocument(document));
	return {
		getId() {
			return 'html';
		},
		doComplete(document: TextDocument, position: Position, settings = workspace.settings) {
			let options = settings && settings.html && settings.html.suggest;
			let doAutoComplete = settings && settings.html && settings.html.autoClosingTags;
			if (doAutoComplete) {
				options.hideAutoCompleteProposals = true;
			}
			let pathCompletionProposals: CompletionItem[] = [];
			let participants = [getPathCompletionParticipant(document, workspace.folders, pathCompletionProposals)];
			htmlLanguageService.setCompletionParticipants(participants);

			const htmlDocument = htmlDocuments.get(document);
			let completionList = htmlLanguageService.doComplete(document, position, htmlDocument, options);
			completionList.items.push(...pathCompletionProposals);
			return completionList;
		},
		doHover(document: TextDocument, position: Position) {
			return htmlLanguageService.doHover(document, position, htmlDocuments.get(document));
		},
		findDocumentHighlight(document: TextDocument, position: Position) {
			return htmlLanguageService.findDocumentHighlights(document, position, htmlDocuments.get(document));
		},
		findDocumentLinks(document: TextDocument, documentContext: DocumentContext) {
			return htmlLanguageService.findDocumentLinks(document, documentContext);
		},
		findDocumentSymbols(document: TextDocument) {
			return htmlLanguageService.findDocumentSymbols(document, htmlDocuments.get(document));
		},
		format(document: TextDocument, range: Range, formatParams: FormattingOptions, settings = workspace.settings) {
			let formatSettings: HTMLFormatConfiguration = settings && settings.html && settings.html.format;
			if (formatSettings) {
				formatSettings = merge(formatSettings, {});
			} else {
				formatSettings = {};
			}
			if (formatSettings.contentUnformatted) {
				formatSettings.contentUnformatted = formatSettings.contentUnformatted + ',script';
			} else {
				formatSettings.contentUnformatted = 'script';
			}
			formatSettings = merge(formatParams, formatSettings);
			return htmlLanguageService.format(document, range, formatSettings);
		},
		getFoldingRanges(document: TextDocument, range: Range): FoldingRange[] {
			let ranges = htmlLanguageService.getFoldingRanges(document);
			return ranges.filter(r => r.startLine >= range.start.line && r.endLine < range.end.line);
		},
		doAutoClose(document: TextDocument, position: Position) {
			let offset = document.offsetAt(position);
			let text = document.getText();
			if (offset > 0 && text.charAt(offset - 1).match(/[>\/]/g)) {
				return htmlLanguageService.doTagComplete(document, position, htmlDocuments.get(document));
			}
			return null;
		},
		onDocumentRemoved(document: TextDocument) {
			htmlDocuments.onDocumentRemoved(document);
		},
		dispose() {
			htmlDocuments.dispose();
		}
	};
}
开发者ID:AllureFer,项目名称:vscode,代码行数:68,代码来源:htmlMode.ts


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