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


TypeScript TextDocument.create方法代码示例

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


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

示例1: assertStyleSheet

function assertStyleSheet(input: string, ...rules: Rule[]): void {
	let p = new Parser();
	let document = TextDocument.create('test://test/test.css', 'css', 0, input);
	let node = p.parseStylesheet(document);

	assertEntries(node, rules);
}
开发者ID:robspassky,项目名称:vscode,代码行数:7,代码来源:lint.test.ts

示例2: getOutline

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

		var symbolProvider = new JSONDocumentSymbols();

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

示例3: assertColor

export function assertColor(parser: Parser, text: string, selection: string, isColor: boolean): void {
	let document = TextDocument.create('test://test/test.css', 'css', 0, text);
	let stylesheet = parser.parseStylesheet(document);
	assert.equal(0, nodes.ParseErrorCollector.entries(stylesheet).length, 'compile errors');

	let node = nodes.getNodeAtOffset(stylesheet, text.indexOf(selection));

	assert.equal(isColor, languageFacts.isColorValue(node));
}
开发者ID:robspassky,项目名称:vscode,代码行数:9,代码来源:languageFacts.test.ts

示例4: parseSelector

export function parseSelector(p: Parser, input: string, selectorName: string, expected: string): void {
	let document = TextDocument.create('test://test/test.css', 'css', 0, input);
	let styleSheet = p.parseStylesheet(document);

	let node = nodes.getNodeAtOffset(styleSheet, input.indexOf(selectorName));
	let selector = node.findParent(nodes.NodeType.Selector);

	let element = selectorPrinter.selectorToElement(selector);
	assert.equal(elementToString(element), expected);
}
开发者ID:robspassky,项目名称:vscode,代码行数:10,代码来源:selectorPrinting.test.ts

示例5: createScope

function createScope(p: Parser, input: string): Scope {
	let document = TextDocument.create('test://test/test.css', 'css', 0, input);

	let styleSheet = p.parseStylesheet(document),
		global = new GlobalScope(),
		builder = new ScopeBuilder(global);

	assertNoErrors(styleSheet);
	styleSheet.accept(builder);
	return global;
}
开发者ID:DiLRandI,项目名称:vscode,代码行数:11,代码来源:navigation.test.ts

示例6: assertRanges

function assertRanges(lines: string[], expected: ExpectedIndentRange[], nRanges?: number): void {
	let document = TextDocument.create('test://foo/bar.json', 'json', 1, lines.join('\n'));
	let actual = getFoldingRegions(document, nRanges, null)!.ranges;

	let actualRanges = [];
	for (let i = 0; i < actual.length; i++) {
		actualRanges[i] = r(actual[i].startLine, actual[i].endLine, actual[i].type);
	}
	actualRanges = actualRanges.sort((r1, r2) => r1.startLine - r2.startLine);
	assert.deepEqual(actualRanges, expected);
}
开发者ID:costincaraivan,项目名称:vscode,代码行数:11,代码来源:folding.test.ts

示例7: it

 it('should return the info of the symbol at the position', () => {
     let ghcModOutput = ['Symbol', 'Info'];
     let position = Position.create(0, 5);
     let logger: ILogger = new TestLogger();
     let ghcMod: IGhcMod = new TestGhcMod(ghcModOutput);
     let provider: IGhcModProvider = new GhcModProvider(ghcMod,  '', logger );
     let document: TextDocument = TextDocument.create('uri', 'languageId', 1, 'Any text');
     return provider.getInfo(document, null, position, false).then((info) => {
         assert.equal(info, 'Symbol\nInfo');
     });
 });
开发者ID:gdziadkiewicz,项目名称:vscode-ghc-mod,代码行数:11,代码来源:ghcModProvider.spec.ts

示例8: 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 = TextDocument.create(uri, 'json', 0, 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 = TextDocument.create(uri, 'json', 0, unformatted);
		let edits = Formatter.format(document, range, { tabSize: 2, insertSpaces: insertSpaces });
		let formatted  = applyEdits(document, edits);
		assert.equal(formatted, expected);
	}
开发者ID:DiLRandI,项目名称:vscode,代码行数:20,代码来源:formatter.test.ts

示例9: 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 = TextDocument.create(uri, 'json', 0, value);
		var jsonDoc = Parser.parse(value);
		return hoverProvider.doHover(document, position, jsonDoc);
	}
开发者ID:DiLRandI,项目名称:vscode,代码行数:12,代码来源:hover.test.ts

示例10: assertRanges

function assertRanges(lines: string[], expected: ExpectedIndentRange[], message?: string, nRanges?: number): void {
	let document = TextDocument.create('test://foo/bar.json', 'json', 1, lines.join('\n'));
	let workspace = {
		settings: {},
		folders: [{ name: 'foo', uri: 'test://foo' }]
	};
	let languageModes = getLanguageModes({ css: true, javascript: true }, workspace);
	let actual = getFoldingRanges(languageModes, document, nRanges, null);

	let actualRanges = [];
	for (let i = 0; i < actual.length; i++) {
		actualRanges[i] = r(actual[i].startLine, actual[i].endLine, actual[i].kind);
	}
	actualRanges = actualRanges.sort((r1, r2) => r1.startLine - r2.startLine);
	assert.deepEqual(actualRanges, expected, message);
}
开发者ID:AllureFer,项目名称:vscode,代码行数:16,代码来源:folding.test.ts


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