Skip to content

Commit 88c1d00

Browse files
Enhance Go/Shell semantic analysis and add ContextBuilder
- Upgrade `GoParser` to use tree-sitter-go for deep extraction (structs, methods, complexity). - Upgrade `ShellParser` to use tree-sitter-bash for function, variable, and command extraction. - Implement `ContextBuilder` for token-aware context assembly with compression strategies. - Update `GoSemanticSnapshotBuilder` and `ShellSemanticSnapshotBuilder` to populate new metadata. - Add tree-sitter queries in `resources/queries/`. - Add unit tests for parsers and context builder.
1 parent a3c4245 commit 88c1d00

File tree

13 files changed

+1467
-134
lines changed

13 files changed

+1467
-134
lines changed

codesage/analyzers/ast_models.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ class ASTNode(BaseModel):
99
# A generic property to hold things like operator/operand values
1010
value: Any = None
1111

12+
class VariableNode(ASTNode):
13+
name: str
14+
value: Optional[str] = None
15+
kind: str = "global" # global, local, field (for structs)
16+
type_name: Optional[str] = None # For typed variables (Go)
17+
is_exported: bool = False
18+
1219
class FunctionNode(ASTNode):
1320
name: str
1421
params: List[str] = []
1522
return_type: Optional[str] = None
23+
receiver: Optional[str] = None # For Go methods
1624
is_async: bool = False
1725
decorators: List[str] = []
1826
complexity: int = 1
@@ -23,14 +31,18 @@ class FunctionNode(ASTNode):
2331
class ClassNode(ASTNode):
2432
name: str
2533
methods: List[FunctionNode] = []
34+
fields: List[VariableNode] = [] # For structs
35+
base_classes: List[str] = []
2636

2737
class ImportNode(ASTNode):
2838
path: str
39+
alias: Optional[str] = None
2940

3041
class FileAST(BaseModel):
3142
path: str
3243
functions: List[FunctionNode] = []
33-
classes: List[ClassNode] = []
44+
classes: List[ClassNode] = [] # Classes, Structs, Interfaces
45+
variables: List[VariableNode] = []
3446
imports: List[ImportNode] = []
3547
# The root of the raw AST tree
3648
tree: Optional[ASTNode] = None

0 commit comments

Comments
 (0)