-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
38 lines (36 loc) · 1.47 KB
/
node.go
File metadata and controls
38 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package model
// CodeNode mirrors src/main/java/.../model/CodeNode.java.
//
// Field naming follows snake_case JSON for parity-diffing against a normalized
// SQLite dump. The Java side uses Jackson defaults (camelCase) but the parity
// harness normalizes both sides via a shared shape (see parity/normalize.go),
// so what matters is internal consistency on the Go side.
type CodeNode struct {
ID string `json:"id"`
Kind NodeKind `json:"kind"`
Label string `json:"label"`
FQN string `json:"fqn,omitempty"`
Module string `json:"module,omitempty"`
FilePath string `json:"file_path,omitempty"`
LineStart int `json:"line_start,omitempty"`
LineEnd int `json:"line_end,omitempty"`
Layer Layer `json:"layer"`
Confidence Confidence `json:"confidence"`
Source string `json:"source,omitempty"`
Annotations []string `json:"annotations"`
Properties map[string]any `json:"properties"`
}
// NewCodeNode constructs a node with required fields populated and slices/maps
// pre-allocated. Defaults Confidence to LEXICAL and Layer to LayerUnknown,
// matching Java behaviour.
func NewCodeNode(id string, kind NodeKind, label string) *CodeNode {
return &CodeNode{
ID: id,
Kind: kind,
Label: label,
Layer: LayerUnknown,
Confidence: ConfidenceLexical,
Annotations: []string{},
Properties: map[string]any{},
}
}