|
4 | 4 |
|
5 | 5 | use baml_base::{Name, SourceFile}; |
6 | 6 | use baml_parser::syntax_tree; |
7 | | -use baml_syntax::SyntaxKind; |
8 | 7 | use baml_workspace::project_files; |
9 | 8 |
|
10 | 9 | mod ids; |
11 | | -mod pretty_print; |
12 | 10 | mod types; |
13 | 11 |
|
14 | 12 | pub use ids::*; |
15 | | -pub use pretty_print::*; |
16 | 13 | pub use types::*; |
17 | 14 |
|
18 | 15 | /// Tracked: get all items defined in a file |
19 | 16 | #[salsa::tracked] |
20 | 17 | pub fn file_items(db: &dyn salsa::Database, file: SourceFile) -> Vec<ItemId> { |
21 | | - return vec![]; |
22 | | - let tree = syntax_tree(db, file); |
23 | | - let file_id = file.file_id(db); |
24 | | - let mut items = Vec::new(); |
25 | | - |
26 | | - // Walk top-level nodes in the syntax tree |
27 | | - // Note: syntax_tree returns a GreenNode, so we need to look at it correctly |
28 | | - |
29 | | - // Iterate children_with_tokens and filter to only SyntaxNodes |
30 | | - for element in tree.children_with_tokens() { |
31 | | - // Only process SyntaxNode elements (not tokens) |
32 | | - if let Some(child) = element.into_node() { |
33 | | - match child.kind() { |
34 | | - SyntaxKind::FUNCTION_DEF => { |
35 | | - // Extract function name - WORD is a token, not a node |
36 | | - for element in child.children_with_tokens() { |
37 | | - if let Some(token) = element.into_token() { |
38 | | - if token.kind() == SyntaxKind::WORD { |
39 | | - let name_text = token.text().to_string(); |
40 | | - let name = Name::new(&name_text); |
41 | | - items.push(ItemId::Function(FunctionId { |
42 | | - file: file_id, |
43 | | - name, |
44 | | - })); |
45 | | - break; |
46 | | - } |
47 | | - } |
48 | | - } |
49 | | - } |
50 | | - SyntaxKind::CLASS_DEF => { |
51 | | - // Extract class name - WORD is a token, not a node |
52 | | - for element in child.children_with_tokens() { |
53 | | - if let Some(token) = element.into_token() { |
54 | | - if token.kind() == SyntaxKind::WORD { |
55 | | - let name_text = token.text().to_string(); |
56 | | - let name = Name::new(&name_text); |
57 | | - items.push(ItemId::Class(ClassId { |
58 | | - file: file_id, |
59 | | - name, |
60 | | - })); |
61 | | - break; |
62 | | - } |
63 | | - } |
64 | | - } |
65 | | - } |
66 | | - SyntaxKind::ENUM_DEF => { |
67 | | - // Extract enum name - WORD is a token, not a node |
68 | | - for element in child.children_with_tokens() { |
69 | | - if let Some(token) = element.into_token() { |
70 | | - if token.kind() == SyntaxKind::WORD { |
71 | | - let name_text = token.text().to_string(); |
72 | | - let name = Name::new(&name_text); |
73 | | - items.push(ItemId::Enum(EnumId { |
74 | | - file: file_id, |
75 | | - name, |
76 | | - })); |
77 | | - break; |
78 | | - } |
79 | | - } |
80 | | - } |
81 | | - } |
82 | | - _ => {} // Skip other nodes |
83 | | - } |
84 | | - } |
85 | | - } |
86 | | - |
87 | | - items |
| 18 | + // TODO: Extract items from syntax tree |
| 19 | + let _tree = syntax_tree(db, file); |
| 20 | + vec![] |
88 | 21 | } |
89 | 22 |
|
90 | 23 | /// Tracked: get all items in the entire project |
|
0 commit comments