Skip to content

Commit 24f83e3

Browse files
committed
update
1 parent 2a899e5 commit 24f83e3

File tree

4 files changed

+10
-66
lines changed

4 files changed

+10
-66
lines changed

python/src/lsap/locate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""Refer to [document](docs/locate_design.md) for design details."""
2-
31
import re
42
from pathlib import Path
53
from typing import Protocol

python/src/lsap/reference.py

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@
33

44
import asyncer
55
from attrs import Factory, define
6-
from lsap_schema.models import (
7-
Location as LSAPLocation,
8-
)
9-
from lsap_schema.models import (
10-
Position,
11-
Range,
12-
SymbolDetailInfo,
13-
SymbolKind,
14-
)
6+
from lsap_schema.models import Location as LSAPLocation
7+
from lsap_schema.models import Position, Range, SymbolDetailInfo, SymbolKind
158
from lsap_schema.reference import ReferenceItem, ReferenceRequest, ReferenceResponse
169
from lsp_client.capability.request import (
1710
WithRequestDocumentSymbol,
@@ -66,7 +59,7 @@ async def fetcher() -> list[ReferenceItem] | None:
6659
if refs := await self.client.request_references(
6760
file_path, lsp_pos, include_declaration=True
6861
):
69-
locations.extend(refs) # type: ignore
62+
locations.extend(refs)
7063
elif req.mode == "implementations":
7164
if impls := await self.client.request_implementation_locations(
7265
file_path, lsp_pos
@@ -110,8 +103,8 @@ async def _process_reference(
110103
content = await self.client.read_file(file_path)
111104
reader = DocumentReader(content)
112105

113-
range_ = loc.range
114-
line = range_.start.line
106+
range = loc.range
107+
line = range.start.line
115108
context_range = LSPRange(
116109
start=LSPPosition(line=max(0, line - context_lines), character=0),
117110
end=LSPPosition(line=line + context_lines + 1, character=0),
@@ -121,7 +114,7 @@ async def _process_reference(
121114

122115
symbol: SymbolDetailInfo | None = None
123116
if symbols := await self.client.request_document_symbol_list(file_path):
124-
if match := symbol_at(symbols, range_.start):
117+
if match := symbol_at(symbols, range.start):
125118
path, sym = match
126119
kind = SymbolKind.from_lsp(sym.kind)
127120

@@ -131,69 +124,22 @@ async def _process_reference(
131124
path=path,
132125
kind=kind,
133126
detail=sym.detail,
134-
hover="",
135127
range=Range(
136128
start=Position.from_lsp(sym.range.start),
137129
end=Position.from_lsp(sym.range.end),
138130
),
139131
)
140-
if hover := await self.client.request_hover(file_path, range_.start):
141-
symbol.hover = hover.value
142132

143-
items.append(
144-
ReferenceItem(
145-
location=LSAPLocation(
146-
file_path=file_path,
147-
range=Range(
148-
start=Position.from_lsp(range_.start),
149-
end=Position.from_lsp(range_.end),
150-
),
151-
),
152-
code=snippet.content,
153-
symbol=symbol,
154-
)
155-
)
156-
157-
file_path = self.client.from_uri(uri)
158-
content = await self.client.read_file(file_path)
159-
reader = DocumentReader(content)
160-
161-
line = range_.start.line
162-
context_range = LSPRange(
163-
start=LSPPosition(line=max(0, line - context_lines), character=0),
164-
end=LSPPosition(line=line + context_lines + 1, character=0),
165-
)
166-
if not (snippet := reader.read(context_range)):
167-
return
168-
169-
symbol: SymbolDetailInfo | None = None
170-
if symbols := await self.client.request_document_symbol_list(file_path):
171-
if match := symbol_at(symbols, range_.start):
172-
path, sym = match
173-
kind = SymbolKind.from_lsp(sym.kind)
174-
175-
symbol = SymbolDetailInfo(
176-
file_path=file_path,
177-
name=sym.name,
178-
path=path,
179-
kind=kind,
180-
detail=sym.detail,
181-
hover="",
182-
range=Range(
183-
start=Position.from_lsp(sym.range.start),
184-
end=Position.from_lsp(sym.range.end),
185-
),
186-
)
187-
if hover := await self.client.request_hover(file_path, range_.start):
133+
if hover := await self.client.request_hover(file_path, range.start):
188134
symbol.hover = hover.value
189135

190136
items.append(
191137
ReferenceItem(
192138
location=LSAPLocation(
193139
file_path=file_path,
194140
range=Range(
195-
start=Position.from_lsp(range_.start),
196-
end=Position.from_lsp(range_.end),
141+
start=Position.from_lsp(range.start),
142+
end=Position.from_lsp(range.end),
197143
),
198144
),
199145
code=snippet.content,

python/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)