本文整理汇总了TypeScript中vscode-languageserver-types.Range类的典型用法代码示例。如果您正苦于以下问题:TypeScript Range类的具体用法?TypeScript Range怎么用?TypeScript Range使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Range类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fn
let promise = new Promise<TextEdit[]>(resolve => {
fn()
let edit: TextEdit = {
newText: 'foo',
range: Range.create(0, 0, 0, 0)
}
resolve([edit])
})
示例2:
const ranges = applicableRanges.map(pair => {
return {
range: Range.create(
document.positionAt(pair[0]),
document.positionAt(pair[1])
),
kind: SelectionRangeKind.Statement
};
});
示例3: it
it('should get quickfix item from Location', async () => {
let filepath = await createTmpFile('quickfix')
let uri = URI.file(filepath).toString()
let p = Position.create(0, 0)
let loc = Location.create(uri, Range.create(p, p))
let item = await workspace.getQuickfixItem(loc)
expect(item.filename).toBe(filepath)
expect(item.text).toBe('quickfix')
})
示例4: test
test('CodeLens', () => {
let codeLens = CodeLens.create(Range.create(1,2,8,9), 'data');
let range = codeLens.range;
strictEqual(range.start.line, 1);
strictEqual(range.start.character, 2);
strictEqual(range.end.line, 8);
strictEqual(range.end.character, 9);
strictEqual(codeLens.data, 'data');
});
示例5: test
test('Interpolation', () => {
testSymbolsFor('<div>{{test}}</div>', [
{
containerName: '',
name: 'div',
kind: SymbolKind.Field,
location: Location.create(TEST_URI, Range.create(0, 0, 0, 19))
}
]);
});
示例6: _selectorCallSymbol
/**
* Handler for selector call symbols
* @param {Object} node
* @param {String[]} text - text editor content splitted by lines
* @return {SymbolInformation}
*/
function _selectorCallSymbol(node: StylusNode, text: string[]): SymbolInformation {
const lineno = Number(node.lineno) - 1;
const name = prepareName(text[lineno]);
const column = Math.max(text[lineno].indexOf(name), 0);
const posStart = Position.create(lineno, column);
const posEnd = Position.create(lineno, column + name.length);
return SymbolInformation.create(name, SymbolKind.Class, Range.create(posStart, posEnd));
}
示例7: _functionSymbol
/**
* Handler for function
* @param {Object} node
* @param {String[]} text - text editor content splitted by lines
* @return {SymbolInformation}
*/
function _functionSymbol(node: StylusNode, text: string[]): SymbolInformation {
const name = node.name;
const lineno = Number(node.val!.lineno) - 1;
const column = Math.max(text[lineno].indexOf(name), 0);
const posStart = Position.create(lineno, column);
const posEnd = Position.create(lineno, column + name.length);
const range = Range.create(posStart, posEnd);
return SymbolInformation.create(name, SymbolKind.Function, range);
}
示例8: createDocument
async function createDocument(): Promise<Document> {
let doc = await helper.createDocument()
let collection = manager.create('test')
let diagnostics: Diagnostic[] = []
await doc.buffer.setLines(['foo bar foo bar', 'foo bar', 'foo', 'bar'], {
start: 0,
end: -1,
strictIndexing: false
})
diagnostics.push(createDiagnostic('error', Range.create(0, 2, 0, 4), DiagnosticSeverity.Error))
diagnostics.push(createDiagnostic('warning', Range.create(0, 5, 0, 6), DiagnosticSeverity.Warning))
diagnostics.push(createDiagnostic('information', Range.create(1, 0, 1, 1), DiagnosticSeverity.Information))
diagnostics.push(createDiagnostic('hint', Range.create(1, 2, 1, 3), DiagnosticSeverity.Hint))
diagnostics.push(createDiagnostic('error', Range.create(2, 0, 2, 2), DiagnosticSeverity.Error))
collection.set(doc.uri, diagnostics)
await helper.wait(200)
let buf = manager.buffers.find(b => b.bufnr == doc.bufnr)
await (buf as any).sequence.ready
return doc
}
示例9: toDiagnostic
function toDiagnostic(error: ESLintError): Diagnostic {
const line = error.line - 1;
const column = error.column - 1;
const endLine = error.endLine ? error.endLine - 1 : line;
const endColumn = error.endColumn ? error.endColumn - 1 : column;
return {
range: Range.create(line, column, endLine, endColumn),
message: `\n[${error.ruleId}]\n${error.message}`,
source: 'eslint-plugin-vue',
severity: error.severity === 1 ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error
};
}
示例10: toDiagnostic
function toDiagnostic(error: ESLintError): Diagnostic {
const line = error.line - 1;
const column = error.column - 1;
const endLine = error.endLine ? error.endLine - 1 : line;
const endColumn = error.endColumn ? error.endColumn - 1 : column;
return {
range: Range.create(line, column, endLine, endColumn),
message: error.message,
source: 'vue-language-server',
severity: error.severity === 1 ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error
};
}