本文整理汇总了TypeScript中vscode-languageserver-types.Location类的典型用法代码示例。如果您正苦于以下问题:TypeScript Location类的具体用法?TypeScript Location怎么用?TypeScript Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Location类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Id and classes', function () {
const content = '<html id=\'root\'><body id="Foo" class="bar"><div class="a b"></div></body></html>';
const expected = [
{
name: 'html#root',
kind: SymbolKind.Field,
containerName: '',
location: Location.create(TEST_URI, Range.create(0, 0, 0, 80))
},
{
name: 'body#Foo.bar',
kind: SymbolKind.Field,
containerName: 'html#root',
location: Location.create(TEST_URI, Range.create(0, 16, 0, 73))
},
{
name: 'div.a.b',
kind: SymbolKind.Field,
containerName: 'body#Foo.bar',
location: Location.create(TEST_URI, Range.create(0, 43, 0, 66))
}
];
testSymbolsFor(content, expected);
});
示例2: 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')
})
示例3: plan
plan(3, async () => {
const fileText = trimLiteral`
| .gaga {
| -st-states: active;
| color: red;
|}
|
|.gaga:active .gaga {
| background-color: fuchsia;
|}
|
|.lokal {
| -st-extends: gaga;
|}
|
|.mixed {
| -st-mixin: lokal,
| gaga, lokal,
| gaga;
|}`;
const fileName = 'references.st.css';
const fileSystem = new MemoryFileSystem('', { content: { [fileName]: fileText } });
init(fileSystem, testCon.server);
const context = { includeDeclaration: true };
const textDocument = TextDocumentItem.create(
toVscodePath('/' + fileName),
'stylable',
0,
fileSystem.loadTextFileSync(fileName)
);
const refsInSelector = await testCon.client.references({
context,
textDocument,
position: { line: 5, character: 16 }
});
const refsInMixin = await testCon.client.references({
context,
textDocument,
position: { line: 10, character: 25 }
});
const refsInExtends = await testCon.client.references({
context,
textDocument,
position: { line: 15, character: 6 }
});
const expectedRefs = [
// Refs should be listed in the order they appear in the file
Location.create(textDocument.uri, createRange(0, 3, 0, 7)),
Location.create(textDocument.uri, createRange(5, 1, 5, 5)),
Location.create(textDocument.uri, createRange(5, 14, 5, 18)),
Location.create(textDocument.uri, createRange(10, 22, 10, 26)),
Location.create(textDocument.uri, createRange(15, 4, 15, 8)),
Location.create(textDocument.uri, createRange(16, 4, 16, 8))
];
expect(refsInSelector).to.eql(expectedRefs);
expect(refsInMixin).to.eql(expectedRefs);
expect(refsInExtends).to.eql(expectedRefs);
})
示例4:
return res.map(loc => Location.create(toVscodePath(loc.uri), loc.range));
示例5: test
test('basic symbols', () => {
let p = new Parser();
assertSymbols(p, '.foo {}', [{ name: '.foo', kind: SymbolKind.Class, location: Location.create('test://test/test.css' ,newRange(0, 7)) }]);
assertSymbols(p, '.foo:not(.selected) {}', [{ name: '.foo:not(.selected)', kind: SymbolKind.Class, location: Location.create('test://test/test.css' ,newRange(0, 22)) }]);
});