mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-21 12:58:33 +00:00
[ty] Refactor inlay hints structure to use separate parts (#20052)
## Summary Our internal inlay hints structure (`ty_ide::InlayHint`) now more closely resembles `lsp_types::InlayHint`. This mainly allows us to convert to `lsp_types::InlayHint` with less hassle, but it also allows us to manage the different parts of the inlay hint better, which in the future will allow us to implement features like goto on the type part of the type inlay hint. It also really isn't important to store a specific `Type` instance in the `InlayHintContent`. So we remove this and use `InlayHintLabel` instead which just shows the representation of the type (along with other information). We see a similar structure used in rust-analyzer too.
This commit is contained in:
parent
ef4897f9f3
commit
8d6dc7d3a3
5 changed files with 147 additions and 61 deletions
|
|
@ -449,14 +449,14 @@ impl Workspace {
|
|||
Ok(result
|
||||
.into_iter()
|
||||
.map(|hint| InlayHint {
|
||||
markdown: hint.display(&self.db).to_string(),
|
||||
markdown: hint.display().to_string(),
|
||||
position: Position::from_text_size(
|
||||
hint.position,
|
||||
&index,
|
||||
&source,
|
||||
self.position_encoding,
|
||||
),
|
||||
kind: hint.content.into(),
|
||||
kind: hint.kind.into(),
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
|
@ -988,11 +988,11 @@ pub enum InlayHintKind {
|
|||
Parameter,
|
||||
}
|
||||
|
||||
impl From<ty_ide::InlayHintContent<'_>> for InlayHintKind {
|
||||
fn from(kind: ty_ide::InlayHintContent) -> Self {
|
||||
impl From<ty_ide::InlayHintKind> for InlayHintKind {
|
||||
fn from(kind: ty_ide::InlayHintKind) -> Self {
|
||||
match kind {
|
||||
ty_ide::InlayHintContent::Type(_) => Self::Type,
|
||||
ty_ide::InlayHintContent::CallArgumentName(_) => Self::Parameter,
|
||||
ty_ide::InlayHintKind::Type => Self::Type,
|
||||
ty_ide::InlayHintKind::CallArgumentName => Self::Parameter,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue