本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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');
});
});
示例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);
}
示例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);
}
示例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);
}