本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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;
})
};