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
14 changes: 6 additions & 8 deletions ast/src/lang/queries/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ impl Stack for Cpp {
fn class_definition_query(&self) -> String {
format!(
r#"
(translation_unit
(class_specifier
name: (type_identifier)@{CLASS_NAME}
(base_class_clause
(type_identifier)@{CLASS_PARENT}
)?
)@{CLASS_DEFINITION}
)
(class_specifier
name: (type_identifier)@{CLASS_NAME}
(base_class_clause
(type_identifier)@{CLASS_PARENT}
)?
)@{CLASS_DEFINITION}
"#
)
}
Expand Down
28 changes: 27 additions & 1 deletion ast/src/lang/queries/kotlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ impl Stack for Kotlin {
(user_type)@{CLASS_PARENT}
)
)?


)@{CLASS_DEFINITION}
(object_declaration
(modifiers (annotation)*)? @{ATTRIBUTES}
(type_identifier)@{CLASS_NAME}
(delegation_specifier
(constructor_invocation
(user_type)@{CLASS_PARENT}
)
)?

)@{CLASS_DEFINITION}
"#
)
Expand Down Expand Up @@ -131,6 +141,19 @@ impl Stack for Kotlin {
)
)

(
(object_declaration
(type_identifier)? @{PARENT_TYPE}
(class_body
(function_declaration
(modifiers (annotation)*)? @{ATTRIBUTES}
(simple_identifier) @{FUNCTION_NAME}
(function_value_parameters) @{ARGUMENTS}
) @{FUNCTION_DEFINITION}
)
)
)

(
(function_declaration
(modifiers (annotation)*)? @{ATTRIBUTES}
Expand Down Expand Up @@ -261,6 +284,9 @@ impl Stack for Kotlin {
Some(format!(
"(class_declaration
(type_identifier) @{STRUCT_NAME}
) @{STRUCT}
(object_declaration
(type_identifier) @{STRUCT_NAME}
) @{STRUCT}"
))
}
Expand Down
6 changes: 3 additions & 3 deletions ast/src/testing/coverage/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn test_btreemap_graph_structure() -> Result<()> {
assert_eq!(endpoints.len(), 3);

let functions = graph.find_nodes_by_type(NodeType::Function);
assert_eq!(functions.len(), 110);
assert_eq!(functions.len(), 112);

let unit_tests = graph.find_nodes_by_type(NodeType::UnitTest);
assert_eq!(unit_tests.len(), 8);
Expand All @@ -83,7 +83,7 @@ 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(), 1);
assert_eq!(classes.len(), 3);

let data_models = graph.find_nodes_by_type(NodeType::DataModel);
assert_eq!(data_models.len(), 1);
Expand Down Expand Up @@ -111,7 +111,7 @@ async fn test_btreemap_test_to_function_edges() -> Result<()> {
assert_eq!(calls_edges, 13);

let contains_edges = graph.count_edges_of_type(EdgeType::Contains);
assert_eq!(contains_edges, 226);
assert_eq!(contains_edges, 232);

let handler_edges = graph.count_edges_of_type(EdgeType::Handler);
assert_eq!(handler_edges, 3);
Expand Down
6 changes: 3 additions & 3 deletions ast/src/testing/coverage/kotlin.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(), 16);
assert_eq!(classes.len(), 18);

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

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

let contains_edges = graph.count_edges_of_type(EdgeType::Contains);
assert_eq!(contains_edges, 219);
assert_eq!(contains_edges, 222);

let handler_edges = graph.count_edges_of_type(EdgeType::Handler);
assert_eq!(handler_edges, 0);
Expand Down
23 changes: 23 additions & 0 deletions ast/src/testing/cpp/web_api/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ast node: Class "Config"
// @ast node: Function "getVersion"
// @ast node: Class "Wrapper"
// @ast node: Function "getValue"
#pragma once
#include <string>

namespace app {
class Config {
public:
std::string getVersion() { return version; }
private:
std::string version = "1.0";
};
}

template<typename T>
class Wrapper {
public:
T getValue() { return value; }
private:
T value;
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.kotlintestapp.data.models
// @ast node: Class "ApiResult"
// @ast node: Class "Error"
// @ast node: Class "Loading"
// @ast node: Class "Success"
// @ast node: Class "User"
// @ast node: Class "UserRole"
// @ast node: DataModel "ApiResult"
// @ast node: DataModel "Error"
// @ast node: DataModel "Loading"
// @ast node: DataModel "Success"
// @ast node: DataModel "User"
// @ast node: DataModel "UserRole"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.kotlintestapp.viewModels
// @ast node: Class "ApiClient"
// @ast edge: Operand -> Function "fetchPeople" "PersonViewModel.kt"
// @ast node: Class "PersonViewModel"
// @ast edge: Operand -> Function "fetchAndStorePersons" "PersonViewModel.kt"
// @ast edge: Operand -> Function "fetchPersonsFromApi" "PersonViewModel.kt"
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/cli/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn parse_stats_cpp_dir() {

assert_eq!(out.exit_code, 0, "stderr: {}", out.stderr);
assert!(out.stdout.contains("Endpoint 3"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Function 110"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Class 1"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Function 112"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Class 3"), "stdout: {}", out.stdout);
}

// ── search ────────────────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/cli/kotlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn parse_stats_kotlin_dir() {
let out = run_stakgraph(&["--stats", &dir]);

assert_eq!(out.exit_code, 0, "stderr: {}", out.stderr);
assert!(out.stdout.contains("Class 16"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Class 18"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Function 27"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("Request 5"), "stdout: {}", out.stdout);
assert!(out.stdout.contains("UnitTest 3"), "stdout: {}", out.stdout);
Expand Down
Loading