Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def class_decorator(cls):
def wrapper(*args, **kwargs):
return cls(*args, **kwargs)
return wrapper

@class_decorator
class Test:
def __init__(self, x: float):
self.x = x

def test(self) -> float:
return self.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Test():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def decorator(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper

@decorator
def func(x: float) -> float:
test = x

return test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def simple(x):
return x
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# < definition scip-python python snapshot-util 0.1 advanced/__init__:
#documentation (module) advanced

def class_decorator(cls):
# ^^^^^^^^^^^^^^^ definition <enclosing 0, 0, 3, 18> snapshot-util 0.1 advanced/class_decorator().
# documentation ```python
# > def class_decorator(
# > cls
# > ): # -> (*args: Unknown, **kwargs: Unkno...
# > ```
# ^^^ definition snapshot-util 0.1 advanced/class_decorator().(cls)
def wrapper(*args, **kwargs):
# ^^^^^^^ definition <enclosing 1, 4, 2, 35> snapshot-util 0.1 advanced/class_decorator().wrapper().
# documentation ```python
# > def wrapper(
# > *args,
# > **kwargs
# > ):
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/class_decorator().wrapper().(args)
# ^^^^^^ definition snapshot-util 0.1 advanced/class_decorator().wrapper().(kwargs)
return cls(*args, **kwargs)
# ^^^ reference snapshot-util 0.1 advanced/class_decorator().(cls)
# ^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper().(args)
# ^^^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper().(kwargs)
return wrapper
# ^^^^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper().

@class_decorator
#^^^^^^^^^^^^^^^ reference snapshot-util 0.1 advanced/class_decorator().
class Test:
# ^^^^ definition <enclosing 5, 0, 11, 21> snapshot-util 0.1 advanced/Test#
# documentation ```python
# > @class_decorator
# > class Test:
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/Test#
def __init__(self, x: float):
# ^^^^^^^^ definition <enclosing 7, 4, 8, 18> snapshot-util 0.1 advanced/Test#__init__().
# documentation ```python
# > def __init__(
# > self,
# > x: float
# > ) -> None:
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/Test#__init__().(self)
# ^ definition snapshot-util 0.1 advanced/Test#__init__().(x)
# ^^^^^ reference python-stdlib 3.11 builtins/float#
# external documentation ```python
# > (class) float
# > ```
self.x = x
# ^^^^ reference snapshot-util 0.1 advanced/Test#__init__().(self)
# ^ definition snapshot-util 0.1 advanced/Test#x.
# documentation ```python
# > (variable) x: float
# > ```
# ^ reference snapshot-util 0.1 advanced/Test#__init__().(x)

def test(self) -> float:
# ^^^^ definition <enclosing 10, 4, 11, 21> snapshot-util 0.1 advanced/Test#test().
# documentation ```python
# > def test(
# > self
# > ) -> float:
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/Test#test().(self)
# ^^^^^ reference python-stdlib 3.11 builtins/float#
return self.x
# ^^^^ reference snapshot-util 0.1 advanced/Test#test().(self)
# ^ reference snapshot-util 0.1 advanced/Test#x.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# < definition scip-python python snapshot-util 0.1 simple/__init__:
#documentation (module) simple

class Test():
# ^^^^ definition <enclosing 0, 0, 1, 6> snapshot-util 0.1 simple/Test#
# documentation ```python
# > class Test:
# > ```
# ^^^^ definition snapshot-util 0.1 simple/Test#
pass

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# < definition scip-python python snapshot-util 0.1 advanced/__init__:
#documentation (module) advanced

def decorator(func):
# ^^^^^^^^^ definition <enclosing 0, 0, 3, 18> snapshot-util 0.1 advanced/decorator().
# documentation ```python
# > def decorator(
# > func
# > ): # -> (*args: Unknown, **kwargs: Unkno...
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/decorator().(func)
def wrapper(*args, **kwargs):
# ^^^^^^^ definition <enclosing 1, 4, 2, 36> snapshot-util 0.1 advanced/decorator().wrapper().
# documentation ```python
# > def wrapper(
# > *args,
# > **kwargs
# > ):
# > ```
# ^^^^ definition snapshot-util 0.1 advanced/decorator().wrapper().(args)
# ^^^^^^ definition snapshot-util 0.1 advanced/decorator().wrapper().(kwargs)
return func(*args, **kwargs)
# ^^^^ reference snapshot-util 0.1 advanced/decorator().(func)
# ^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper().(args)
# ^^^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper().(kwargs)
return wrapper
# ^^^^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper().

@decorator
#^^^^^^^^^ reference snapshot-util 0.1 advanced/decorator().
def func(x: float) -> float:
# ^^^^ definition <enclosing 5, 0, 9, 15> snapshot-util 0.1 advanced/func().
# documentation ```python
# > @decorator
# > def func(
# > x: float
# > ) -> float:
# > ```
# ^ definition snapshot-util 0.1 advanced/func().(x)
# ^^^^^ reference python-stdlib 3.11 builtins/float#
# external documentation ```python
# > (class) float
# > ```
# ^^^^^ reference python-stdlib 3.11 builtins/float#
test = x
# ^^^^ definition local 0
# documentation ```python
# > builtins.float
# > ```
# ^ reference snapshot-util 0.1 advanced/func().(x)

return test
# ^^^^ reference local 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# < definition scip-python python snapshot-util 0.1 simple/__init__:
#documentation (module) simple

def simple(x):
# ^^^^^^ definition <enclosing 0, 0, 1, 10> snapshot-util 0.1 simple/simple().
# documentation ```python
# > def simple(
# > x
# > ):
# > ```
# ^ definition snapshot-util 0.1 simple/simple().(x)
return x
# ^ reference snapshot-util 0.1 simple/simple().(x)

3 changes: 3 additions & 0 deletions packages/pyright-scip/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export function formatSnapshot(
const isDefinition = (occurrence.symbol_roles & scip.SymbolRole.Definition) > 0;
out.push(isDefinition ? 'definition' : 'reference');
out.push(' ');
if (occurrence.enclosing_range.length) {
out.push('<enclosing ' + occurrence.enclosing_range.join(', ') + '>');
}
const symbol = occurrence.symbol.startsWith(packageName)
? occurrence.symbol.slice(packageName.length)
: occurrence.symbol;
Expand Down
Loading