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


TypeScript ITextDocument.create方法代码示例

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


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

示例1: getOutline

	function getOutline(value: string): Promise<SymbolInformation[]> {
		var uri = 'test://test.json';

		var symbolProvider = new JSONDocumentSymbols();

		var document = ITextDocument.create(uri, value);
		var jsonDoc = Parser.parse(value);
		return symbolProvider.compute(document, jsonDoc);
	}
开发者ID:13572293130,项目名称:vscode,代码行数:9,代码来源:documentSymbols.test.ts

示例2: format

	function format(unformatted: string, expected: string, insertSpaces = true) {
		let range: Range = null;
		let uri = 'test://test.json';

		let rangeStart = unformatted.indexOf('|');
		let rangeEnd = unformatted.lastIndexOf('|');
		if (rangeStart !== -1 && rangeEnd !== -1) {
			// remove '|'
			var unformattedDoc = ITextDocument.create(uri, unformatted);
			unformatted = unformatted.substring(0, rangeStart) + unformatted.substring(rangeStart + 1, rangeEnd) + unformatted.substring(rangeEnd + 1);
			let startPos = unformattedDoc.positionAt(rangeStart);
			let endPos = unformattedDoc.positionAt(rangeEnd);
			range = Range.create(startPos, endPos);
		}

		var document = ITextDocument.create(uri, unformatted);
		let edits = Formatter.format(document, range, { tabSize: 2, insertSpaces: insertSpaces });
		let formatted  = applyEdits(document, edits);
		assert.equal(formatted, expected);
	}
开发者ID:1833183060,项目名称:vscode,代码行数:20,代码来源:formatter.test.ts

示例3: testComputeInfo

	function testComputeInfo(value: string, schema: JsonSchema.IJSONSchema, position: Position): Thenable<Hover> {
		var uri = 'test://test.json';

		var schemaService = new SchemaService.JSONSchemaService(requestService);
		var hoverProvider = new JSONHover(schemaService);
		var id = "http://myschemastore/test1";
		schemaService.registerExternalSchema(id, ["*.json"], schema);

		var document = ITextDocument.create(uri, value);
		var textDocumentLocation = TextDocumentPosition.create(uri, position);
		var jsonDoc = Parser.parse(value);
		return hoverProvider.doHover(document, textDocumentLocation, jsonDoc);
	}
开发者ID:13572293130,项目名称:vscode,代码行数:13,代码来源:hover.test.ts

示例4: function

	var testSuggestionsFor = function(value: string, stringAfter: string, schema: JsonSchema.IJSONSchema, test: (items: CompletionItem[], document: ITextDocument) => void) : Thenable<void> {
		var uri = 'test://test.json';
		var idx = stringAfter ? value.indexOf(stringAfter) : 0;

		var schemaService = new SchemaService.JSONSchemaService(requestService);
		var completionProvider = new JSONCompletion(schemaService, console);
		if (schema) {
			var id = "http://myschemastore/test1";
			schemaService.registerExternalSchema(id, ["*.json"], schema);
		}

		var document = ITextDocument.create(uri, value);
		var textDocumentLocation = TextDocumentPosition.create(uri, Position.create(0, idx));
		var jsonDoc = Parser.parse(value);
		return completionProvider.doSuggest(document, textDocumentLocation, jsonDoc).then(list => list.items).then(completions => {
			test(completions, document);
			return null;
		})
	};
开发者ID:578723746,项目名称:vscode,代码行数:19,代码来源:completion.test.ts


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