Skip to content

Commit ed8d157

Browse files
committed
refactor
1 parent 5cae7f6 commit ed8d157

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

crates/ty_ide/src/hover.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,21 @@ pub fn hover(db: &dyn Db, file: File, offset: TextSize) -> Option<RangedValue<Ho
2020
}
2121

2222
let model = SemanticModel::new(db, file);
23-
let ty =
24-
goto_target.inferred_type(&model).map(|ty| match ty {
23+
let ty = goto_target.inferred_type(&model);
24+
let docs = goto_target
25+
.get_definition_targets(
26+
file,
27+
db,
28+
ty_python_semantic::ImportAliasResolution::ResolveAliases,
29+
)
30+
.and_then(|definitions| definitions.docstring(db))
31+
.map(HoverContent::Docstring);
32+
33+
// TODO: Render the symbol's signature instead of just its type.
34+
let mut contents = Vec::new();
35+
if let Some(ty) = ty {
36+
tracing::debug!("Inferred type of covering node is {}", ty.display(db));
37+
contents.push(match ty {
2538
Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) => typevar
2639
.bind_pep695(db)
2740
.map_or(HoverContent::Type(ty, None), |typevar| {
@@ -35,22 +48,7 @@ pub fn hover(db: &dyn Db, file: File, offset: TextSize) -> Option<RangedValue<Ho
3548
}
3649
_ => HoverContent::Type(ty, None),
3750
});
38-
let docs = goto_target
39-
.get_definition_targets(
40-
file,
41-
db,
42-
ty_python_semantic::ImportAliasResolution::ResolveAliases,
43-
)
44-
.and_then(|definitions| definitions.docstring(db))
45-
.map(HoverContent::Docstring);
46-
47-
if let Some(HoverContent::Type(ty, _)) = ty {
48-
tracing::debug!("Inferred type of covering node is {}", ty.display(db));
4951
}
50-
51-
// TODO: Render the symbol's signature instead of just its type.
52-
let mut contents = Vec::new();
53-
contents.extend(ty);
5452
contents.extend(docs);
5553

5654
if contents.is_empty() {

0 commit comments

Comments
 (0)