Skip to content

Commit 64fb7be

Browse files
committed
Revert attributed items inlay hints
1 parent 747f2d1 commit 64fb7be

File tree

2 files changed

+13
-98
lines changed

2 files changed

+13
-98
lines changed

crates/hir/src/semantics.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
184184
self.imp.descend_into_macros(token)
185185
}
186186

187-
pub fn descend_node_at_offset<N: ast::AstNode>(
188-
&self,
189-
node: &SyntaxNode,
190-
offset: TextSize,
191-
) -> Option<N> {
192-
self.imp.descend_node_at_offset(node, offset).flatten().find_map(N::cast)
193-
}
194-
195187
pub fn hir_file_for(&self, syntax_node: &SyntaxNode) -> HirFileId {
196188
self.imp.find_file(syntax_node.clone()).file_id
197189
}

crates/ide/src/inlay_hints.rs

Lines changed: 13 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,24 @@ pub(crate) fn inlay_hints(
6262
let _p = profile::span("inlay_hints");
6363
let sema = Semantics::new(db);
6464
let file = sema.parse(file_id);
65+
let file = file.syntax();
6566

6667
let mut res = Vec::new();
67-
let mut queue = vec![file.syntax().preorder()];
6868

69-
while let Some(mut preorder) = queue.pop() {
70-
while let Some(event) = preorder.next() {
71-
let node = match event {
72-
syntax::WalkEvent::Enter(node) => node,
73-
syntax::WalkEvent::Leave(_) => continue,
74-
};
75-
if let Some(node) =
76-
ast::Item::cast(node.clone()).and_then(|item| sema.expand_attr_macro(&item))
77-
{
78-
preorder.skip_subtree();
79-
queue.push(node.preorder());
80-
continue;
81-
}
82-
83-
if let Some(expr) = ast::Expr::cast(node.clone()) {
84-
get_chaining_hints(&mut res, &sema, config, &expr);
85-
match expr {
86-
ast::Expr::CallExpr(it) => {
87-
get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it));
88-
}
89-
ast::Expr::MethodCallExpr(it) => {
90-
get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it));
91-
}
92-
_ => (),
69+
for node in file.descendants() {
70+
if let Some(expr) = ast::Expr::cast(node.clone()) {
71+
get_chaining_hints(&mut res, &sema, config, &expr);
72+
match expr {
73+
ast::Expr::CallExpr(it) => {
74+
get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it));
75+
}
76+
ast::Expr::MethodCallExpr(it) => {
77+
get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it));
9378
}
94-
} else if let Some(it) = ast::IdentPat::cast(node.clone()) {
95-
get_bind_pat_hints(&mut res, &sema, config, it);
79+
_ => (),
9680
}
81+
} else if let Some(it) = ast::IdentPat::cast(node.clone()) {
82+
get_bind_pat_hints(&mut res, &sema, config, it);
9783
}
9884
}
9985
res
@@ -1485,67 +1471,4 @@ fn main() {
14851471
"#]],
14861472
);
14871473
}
1488-
1489-
#[test]
1490-
fn hints_in_attr_call() {
1491-
// chaining hints do not currently work as macros lose all whitespace information
1492-
check_expect(
1493-
TEST_CONFIG,
1494-
r#"
1495-
//- proc_macros: identity, input_replace
1496-
struct Struct;
1497-
impl Struct {
1498-
fn chain(self) -> Self {
1499-
self
1500-
}
1501-
}
1502-
1503-
#[proc_macros::identity]
1504-
fn main() {
1505-
let strukt = Struct;
1506-
strukt
1507-
.chain()
1508-
.chain()
1509-
.chain();
1510-
Struct::chain(strukt);
1511-
}
1512-
1513-
#[proc_macros::input_replace(
1514-
fn not_main() {
1515-
let strukt = Struct;
1516-
strukt
1517-
.chain()
1518-
.chain()
1519-
.chain();
1520-
Struct::chain(strukt);
1521-
}
1522-
)]
1523-
fn main() {}
1524-
"#,
1525-
expect![[r#"
1526-
[
1527-
InlayHint {
1528-
range: 297..303,
1529-
kind: TypeHint,
1530-
label: "Struct",
1531-
},
1532-
InlayHint {
1533-
range: 415..421,
1534-
kind: ParameterHint,
1535-
label: "self",
1536-
},
1537-
InlayHint {
1538-
range: 125..131,
1539-
kind: TypeHint,
1540-
label: "Struct",
1541-
},
1542-
InlayHint {
1543-
range: 223..229,
1544-
kind: ParameterHint,
1545-
label: "self",
1546-
},
1547-
]
1548-
"#]],
1549-
);
1550-
}
15511474
}

0 commit comments

Comments
 (0)