Skip to content

Commit 28f30f8

Browse files
committed
Inline hover variable type resolution into completion pipeline
1 parent 4349590 commit 28f30f8

6 files changed

Lines changed: 24 additions & 58 deletions

File tree

src/code_actions/extract_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn resolve_var_type(
432432

433433
let current_class = find_class_at_offset(&ctx.classes, cursor_offset);
434434

435-
crate::hover::variable_type::resolve_variable_type(
435+
crate::completion::variable::resolution::resolve_variable_php_type(
436436
var_name,
437437
content,
438438
cursor_offset,

src/completion/phpdoc/generation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ pub(crate) fn infer_inline_variable_type(
17351735

17361736
let current_class = crate::util::find_class_at_offset(all_classes, cursor_offset);
17371737

1738-
crate::hover::variable_type::resolve_variable_type(
1738+
crate::completion::variable::resolution::resolve_variable_php_type(
17391739
var_name,
17401740
effective_content,
17411741
cursor_offset,

src/completion/resolver.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,15 +1056,16 @@ pub(crate) fn resolve_subject_outcome(
10561056
// For bare variables, try the hover fallback for UnresolvableClass
10571057
// detection only.
10581058
if let SubjectExpr::Variable(var_name) = &expr
1059-
&& let Some(resolved_type) = crate::hover::variable_type::resolve_variable_type(
1060-
var_name,
1061-
ctx.content,
1062-
ctx.cursor_offset,
1063-
ctx.current_class,
1064-
ctx.all_classes,
1065-
ctx.class_loader,
1066-
Loaders::with_function(ctx.function_loader),
1067-
)
1059+
&& let Some(resolved_type) =
1060+
crate::completion::variable::resolution::resolve_variable_php_type(
1061+
var_name,
1062+
ctx.content,
1063+
ctx.cursor_offset,
1064+
ctx.current_class,
1065+
ctx.all_classes,
1066+
ctx.class_loader,
1067+
Loaders::with_function(ctx.function_loader),
1068+
)
10681069
&& let Some(unresolved) = check_unresolvable_class_name(&resolved_type, ctx.class_loader)
10691070
{
10701071
return SubjectOutcome::UnresolvableClass(unresolved);

src/completion/variable/raw_type_inference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn infer_element_type<'b>(
158158
.iter()
159159
.find(|c| c.name == ctx.current_class.name)
160160
.map(|c| c.as_ref());
161-
crate::hover::variable_type::resolve_variable_type(
161+
crate::completion::variable::resolution::resolve_variable_php_type(
162162
&var_text,
163163
ctx.content,
164164
offset as u32,

src/hover/mod.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
//! powers completion.
1010
1111
mod formatting;
12-
pub(crate) mod variable_type;
1312

1413
use std::sync::Arc;
1514
use tower_lsp::lsp_types::*;
@@ -982,15 +981,17 @@ impl Backend {
982981
// Try the type-string path first. This preserves generic
983982
// parameters (e.g. `Generator<int, Pencil>`) and scalar types
984983
// (e.g. `int`) that the ClassInfo-based path would lose.
985-
if let Some(resolved_type) = variable_type::resolve_variable_type(
986-
&var_name,
987-
content,
988-
cursor_offset,
989-
current_class,
990-
&ctx.classes,
991-
&class_loader,
992-
loaders,
993-
) {
984+
if let Some(resolved_type) =
985+
crate::completion::variable::resolution::resolve_variable_php_type(
986+
&var_name,
987+
content,
988+
cursor_offset,
989+
current_class,
990+
&ctx.classes,
991+
&class_loader,
992+
loaders,
993+
)
994+
{
994995
// When the type is a template parameter, show its variance
995996
// and bound (e.g. "**template-covariant** `TNode` of `AstNode`")
996997
// above the code block so the user sees the constraint.

src/hover/variable_type.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)