Skip to content

Commit a8ebd76

Browse files
committed
Check pt fixing warnings
1 parent 85a280c commit a8ebd76

File tree

2 files changed

+11
-37
lines changed

2 files changed

+11
-37
lines changed

crates/parser/src/ast_builder.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,13 @@ impl ASTBuilder {
248248
source: &str,
249249
attributes: &mut HashMap<String, String>,
250250
) {
251-
// Debug output for C functions
252-
if self.language == Language::C {
253-
eprintln!("DEBUG: Extracting function attributes from node: {}", node.kind());
254-
eprintln!("DEBUG: Node text: {:?}", node.utf8_text(source.as_bytes()).unwrap_or(""));
255-
}
251+
256252

257253
// Extract function name - try different field names for C
258254
if let Some(declarator) = node.child_by_field_name("declarator") {
259255
if let Ok(_name_text) = declarator.utf8_text(source.as_bytes()) {
260256
// For C, the declarator might contain the function name
261257
if let Some(name) = self.extract_function_name_from_declarator(&declarator, source) {
262-
if self.language == Language::C {
263-
eprintln!("DEBUG: Extracted function name: {}", name);
264-
}
265258
attributes.insert("name".to_string(), name);
266259
}
267260
}

crates/semantic-analysis/src/analyzer.rs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ impl SemanticAnalyzer {
9090
Ok(())
9191
}
9292

93-
fn collect_symbols_recursive(&mut self, node: &ASTNode, file_path: &str, scope_path: &mut Vec<String>) -> Result<(), AnalysisError> {
94-
use crate::symbol_table::{Symbol, SymbolKind, Scope, ScopeType};
95-
use crate::ast::NodeType;
93+
fn collect_symbols_recursive(&mut self, node: &ASTNode, file_path: &str, _scope_path: &mut Vec<String>) -> Result<(), AnalysisError> {
94+
use crate::symbol_table::{Symbol, SymbolKind};
95+
use smart_diff_parser::ast::NodeType;
9696

9797
match node.node_type {
9898
NodeType::Function | NodeType::Method | NodeType::Constructor => {
@@ -101,8 +101,8 @@ impl SemanticAnalyzer {
101101

102102
let symbol = Symbol {
103103
name: name.clone(),
104-
kind: SymbolKind::Function,
105-
scope_id: self.symbol_table.current_scope(),
104+
symbol_kind: SymbolKind::Function,
105+
scope_id: 0, // Use global scope for now
106106
line: node.metadata.line,
107107
column: node.metadata.column,
108108
file_path: file_path.to_string(),
@@ -119,8 +119,8 @@ impl SemanticAnalyzer {
119119

120120
let symbol = Symbol {
121121
name: name.clone(),
122-
kind: SymbolKind::Variable,
123-
scope_id: self.symbol_table.current_scope(),
122+
symbol_kind: SymbolKind::Variable,
123+
scope_id: 0, // Use global scope for now
124124
line: node.metadata.line,
125125
column: node.metadata.column,
126126
file_path: file_path.to_string(),
@@ -135,8 +135,8 @@ impl SemanticAnalyzer {
135135
if let Some(name) = node.metadata.attributes.get("name") {
136136
let symbol = Symbol {
137137
name: name.clone(),
138-
kind: SymbolKind::Type,
139-
scope_id: self.symbol_table.current_scope(),
138+
symbol_kind: SymbolKind::Class,
139+
scope_id: 0, // Use global scope for now
140140
line: node.metadata.line,
141141
column: node.metadata.column,
142142
file_path: file_path.to_string(),
@@ -145,33 +145,14 @@ impl SemanticAnalyzer {
145145
};
146146

147147
self.symbol_table.add_symbol(symbol);
148-
149-
// Create new scope for class
150-
let scope = Scope {
151-
scope_type: ScopeType::Class,
152-
name: Some(name.clone()),
153-
parent: Some(self.symbol_table.current_scope()),
154-
symbols: Vec::new(),
155-
};
156-
let scope_id = self.symbol_table.add_scope(scope);
157-
self.symbol_table.enter_scope(scope_id);
158-
scope_path.push(name.clone());
159148
}
160149
}
161150
_ => {}
162151
}
163152

164153
// Recursively process children
165154
for child in &node.children {
166-
self.collect_symbols_recursive(child, file_path, scope_path)?;
167-
}
168-
169-
// Exit scope if we entered one
170-
if matches!(node.node_type, NodeType::Class | NodeType::Interface) {
171-
if node.metadata.attributes.get("name").is_some() {
172-
self.symbol_table.exit_scope();
173-
scope_path.pop();
174-
}
155+
self.collect_symbols_recursive(child, file_path, _scope_path)?;
175156
}
176157

177158
Ok(())

0 commit comments

Comments
 (0)