Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ast/src/lang/queries/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ impl Stack for Java {
)
)?
)@{CLASS_DEFINITION}
(enum_declaration
name: (identifier)@{CLASS_NAME}
)@{CLASS_DEFINITION}
"#
)
}
Expand Down Expand Up @@ -410,6 +413,9 @@ impl Stack for Java {
(record_declaration
name: (identifier) @{STRUCT_NAME}
) @{STRUCT}
(enum_declaration
name: (identifier) @{STRUCT_NAME}
) @{STRUCT}
(class_declaration
(modifiers) @modifier (#match? @modifier ".final$")
name: (identifier) @{STRUCT_NAME}
Expand Down
6 changes: 3 additions & 3 deletions ast/src/testing/coverage/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ async fn test_btreemap_graph_structure() -> Result<()> {
assert_eq!(e2e_tests.len(), 0);

let classes = graph.find_nodes_by_type(NodeType::Class);
assert_eq!(classes.len(), 20);
assert_eq!(classes.len(), 23);

let data_models = graph.find_nodes_by_type(NodeType::DataModel);
assert_eq!(data_models.len(), 2);
assert_eq!(data_models.len(), 5);

let traits = graph.find_nodes_by_type(NodeType::Trait);
assert_eq!(traits.len(), 2);
Expand All @@ -111,7 +111,7 @@ async fn test_btreemap_test_to_function_edges() -> Result<()> {
assert_eq!(calls_edges, 35);

let contains_edges = graph.count_edges_of_type(EdgeType::Contains);
assert_eq!(contains_edges, 252);
assert_eq!(contains_edges, 260);

let handler_edges = graph.count_edges_of_type(EdgeType::Handler);
assert_eq!(handler_edges, 11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
public record InvoiceRecord(String id, long amount) {
}

// @ast node: Class "BillingStatus"
// @ast node: DataModel "BillingStatus"
enum BillingStatus {
PENDING,
PAID,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package graph.stakgraph.java.nonweb;

// Enum types must be captured as BOTH a Class and a DataModel (mirroring how
// records and Rust enums are handled). Covers package-private and public enums.

// package-private enum
// @ast node: Class "Suit"
// @ast node: DataModel "Suit"
enum Suit {
HEARTS,
DIAMONDS,
CLUBS,
SPADES
}

// public enum
// @ast node: Class "Priority"
// @ast node: DataModel "Priority"
public enum Priority {
LOW,
MEDIUM,
HIGH
}
2 changes: 1 addition & 1 deletion cli/tests/cli/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn parse_stats_java_dir() {

assert_eq!(out.exit_code, 0, "stderr: {}", out.stderr);
assert!(out.stdout.contains("Class 15"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Import 18"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Import 19"), "stdout: {}", out.stdout);
}

// ── search ────────────────────────────────────────────────────────────────────
Expand Down
Loading