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