本文整理匯總了TypeScript中vscode-languageserver-types.Location.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Location.create方法的具體用法?TypeScript Location.create怎麽用?TypeScript Location.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode-languageserver-types.Location
的用法示例。
在下文中一共展示了Location.create方法的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)) }]);
});