Skip to content

Commit 00b7769

Browse files
committed
update
1 parent 90be683 commit 00b7769

File tree

13 files changed

+60
-99
lines changed

13 files changed

+60
-99
lines changed

python/src/lsap/hover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ async def __call__(self, req: HoverRequest) -> HoverResponse | None:
3434
file_path, lsp_pos = loc_resp.file_path, loc_resp.position.to_lsp()
3535
hover = await self.client.request_hover(file_path, lsp_pos)
3636

37-
if not hover:
37+
if hover is None:
3838
return None
3939

4040
contents = ""
41-
if isinstance(hover.contents, str):
41+
if isinstance(hover.value, str):
4242
contents = hover.contents
4343
elif isinstance(hover.contents, list):
4444
contents = "\n".join(

python/src/lsap/symbol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from functools import cached_property
44
from pathlib import Path
5-
from typing import Protocol, override
5+
from typing import Protocol, override, runtime_checkable
66

77
from attrs import define
88
from lsap_schema.symbol import SymbolRequest, SymbolResponse
@@ -18,6 +18,7 @@
1818
from .symbol_outline import SymbolOutlineCapability
1919

2020

21+
@runtime_checkable
2122
class SymbolClient(
2223
WithRequestDocumentSymbol,
2324
WithRequestHover,

schema/src/lsap_schema/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@
8484
)
8585

8686
# Types
87-
from .types import Position, Range, SymbolInfo, SymbolKind
87+
from .types import (
88+
Position,
89+
Range,
90+
SymbolCodeInfo,
91+
SymbolDetailInfo,
92+
SymbolInfo,
93+
SymbolKind,
94+
)
8895

8996
# Workspace
9097
from .workspace_symbol import (
@@ -140,6 +147,8 @@
140147
"SymbolScope",
141148
"Position",
142149
"Range",
150+
"SymbolCodeInfo",
151+
"SymbolDetailInfo",
143152
"SymbolInfo",
144153
"SymbolKind",
145154
# Reference

schema/src/lsap_schema/abc.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ def format(self, template_name: str = "markdown") -> str:
2727
)
2828

2929

30-
class SymbolInfoRequest(Request):
31-
"""
32-
Base request for retrieving symbol information.
33-
"""
34-
35-
include_hover: bool = True
36-
"""Whether to include hover/documentation information"""
37-
38-
include_code: bool = False
39-
"""Whether to include the symbol's source code content"""
40-
41-
4230
class PaginatedRequest(Request):
4331
"""
4432
Base request for paginated results.

schema/src/lsap_schema/definition.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from pydantic import ConfigDict
44

5-
from .abc import Response, SymbolInfoRequest
5+
from .abc import Response
66
from .locate import LocateRequest
7-
from .types import SymbolInfo
7+
from .types import SymbolCodeInfo
88

99

10-
class DefinitionRequest(LocateRequest, SymbolInfoRequest):
10+
class DefinitionRequest(LocateRequest):
1111
"""
1212
Finds the definition, declaration, or type definition of a symbol.
1313
@@ -28,30 +28,19 @@ class DefinitionRequest(LocateRequest, SymbolInfoRequest):
2828
{%- for item in items -%}
2929
## `{{ item.file_path }}`: {{ item.path | join: "." }} (`{{ item.kind }}`)
3030
31-
{% if item.detail -%}
32-
{{ item.detail }}
33-
34-
{% endif -%}
35-
{% if item.hover != nil -%}
36-
### Documentation
37-
{{ item.hover }}
38-
39-
{% endif -%}
40-
{% if item.code != nil -%}
4131
### Content
4232
```{{ item.file_path.suffix | remove_first: "." }}
4333
{{ item.code }}
4434
```
4535
46-
{% endif -%}
47-
{%- endfor -%}
36+
{% endfor -%}
4837
{%- endif %}
4938
"""
5039

5140

5241
class DefinitionResponse(Response):
5342
request: DefinitionRequest
54-
items: list[SymbolInfo]
43+
items: list[SymbolCodeInfo]
5544

5645
model_config = ConfigDict(
5746
json_schema_extra={

schema/src/lsap_schema/hover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class HoverRequest(LocateRequest):
1818
markdown_template: Final = """
1919
# Hover Information
2020
21-
{{ contents }}
21+
{{ content }}
2222
"""
2323

2424

2525
class HoverResponse(Response):
26-
contents: str
26+
content: str
2727
"""The hover content, usually markdown."""
2828

2929
model_config = ConfigDict(

schema/src/lsap_schema/locate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Locate(BaseModel):
6262
"""Text pattern with marker for exact position; if no marker, positions at match start."""
6363

6464
marker: str = HERE
65-
"""Position marker in find pattern. Change if source contains the default '<HERE>'."""
65+
"""Position marker in find pattern. Change this if source contains the default '<HERE>'."""
6666

6767
@model_validator(mode="after")
6868
def check_valid_locate(self):
@@ -79,7 +79,7 @@ def check_valid_locate(self):
7979

8080
class LocateRange(BaseModel):
8181
"""
82-
Locate a range for operations like codeAction.
82+
Locate a range.
8383
8484
Examples:
8585
# Select symbol body

schema/src/lsap_schema/reference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
from .abc import PaginatedRequest, PaginatedResponse
77
from .locate import LocateRequest
8-
from .types import SymbolInfo
8+
from .types import SymbolDetailInfo
99

1010

1111
class ReferenceItem(BaseModel):
1212
file_path: Path
1313
line: int = Field(..., description="1-based line number")
1414
code: str = Field(..., description="Surrounding code snippet")
15-
symbol: SymbolInfo | None = Field(
15+
symbol: SymbolDetailInfo | None = Field(
1616
None, description="The symbol containing this reference"
1717
)
1818

schema/src/lsap_schema/symbol.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,31 @@
22

33
from pydantic import ConfigDict
44

5-
from .abc import Response, SymbolInfoRequest
5+
from .abc import Response
66
from .locate import LocateRequest
7-
from .types import SymbolInfo
7+
from .types import SymbolCodeInfo
88

99

10-
class SymbolRequest(LocateRequest, SymbolInfoRequest):
10+
class SymbolRequest(LocateRequest):
1111
"""
1212
Retrieves detailed information about a symbol at a specific location.
1313
1414
Use this to get the documentation (hover) and source code implementation
1515
of a symbol to understand its purpose and usage.
1616
"""
1717

18-
include_hover: bool = False
19-
"""Whether to include hover/documentation information"""
20-
21-
include_code: bool = True
22-
"""Whether to include the symbol's source code content"""
23-
2418

2519
markdown_template: Final = """
2620
# Symbol: `{{ path | join: "." }}` (`{{ kind }}`) at `{{ file_path }}`
2721
28-
{% if detail != nil -%}
29-
## Detail
30-
{{ detail }}
31-
{%- endif %}
32-
33-
{% if hover != nil -%}
34-
## Documentation
35-
{{ hover }}
36-
{%- endif %}
37-
38-
{% if code != nil -%}
3922
## Implementation
4023
```{{ file_path.suffix | remove_first: "." }}
4124
{{ code }}
4225
```
43-
{%- endif %}
4426
"""
4527

4628

47-
class SymbolResponse(SymbolInfo, Response):
29+
class SymbolResponse(SymbolCodeInfo, Response):
4830
model_config = ConfigDict(
4931
json_schema_extra={
5032
"markdown": markdown_template,

schema/src/lsap_schema/symbol_outline.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
from pydantic import ConfigDict
55

6-
from .abc import Response, SymbolInfoRequest
7-
from .types import SymbolInfo
6+
from .abc import Request, Response
7+
from .types import SymbolDetailInfo
88

99

10-
class SymbolOutlineRequest(SymbolInfoRequest):
10+
class SymbolOutlineRequest(Request):
1111
"""
1212
Retrieves a hierarchical outline of symbols within a file.
1313
@@ -24,20 +24,16 @@ class SymbolOutlineRequest(SymbolInfoRequest):
2424
{% for item in items -%}
2525
{% assign level = item.path | size | plus: 1 -%}
2626
{% for i in (1..level) %}#{% endfor %} {{ item.path | join: "." }} (`{{ item.kind }}`)
27-
{%- if item.detail %}
2827
{{ item.detail }}
29-
{%- endif %}
30-
{%- if item.hover %}
3128
{{ item.hover | strip | truncate: 120 }}
32-
{%- endif %}
3329
3430
{% endfor -%}
3531
"""
3632

3733

3834
class SymbolOutlineResponse(Response):
3935
file_path: Path
40-
items: list[SymbolInfo]
36+
items: list[SymbolDetailInfo]
4137

4238
model_config = ConfigDict(
4339
json_schema_extra={

0 commit comments

Comments
 (0)