From 75ba2cb6b9865557bbd9865ee0f5f6e355d731bb Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Wed, 5 Jun 2024 21:38:43 -0300 Subject: [PATCH] fix(matching): Ignore modifiers when building method signature --- .../method_parameters_differ_on_final_keyword/base.java | 3 +++ .../method_parameters_differ_on_final_keyword/left.java | 3 +++ .../method_parameters_differ_on_final_keyword/merge.java | 1 + .../method_parameters_differ_on_final_keyword/right.java | 3 +++ matching_handlers/src/java/method_declaration.rs | 2 +- 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 bin/tests/scenarios/method_parameters_differ_on_final_keyword/base.java create mode 100644 bin/tests/scenarios/method_parameters_differ_on_final_keyword/left.java create mode 100644 bin/tests/scenarios/method_parameters_differ_on_final_keyword/merge.java create mode 100644 bin/tests/scenarios/method_parameters_differ_on_final_keyword/right.java diff --git a/bin/tests/scenarios/method_parameters_differ_on_final_keyword/base.java b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/base.java new file mode 100644 index 0000000..023f369 --- /dev/null +++ b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/base.java @@ -0,0 +1,3 @@ +public abstract class Artifact { + public abstract T addChild(final T child) throws IOException; +} diff --git a/bin/tests/scenarios/method_parameters_differ_on_final_keyword/left.java b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/left.java new file mode 100644 index 0000000..8311bf5 --- /dev/null +++ b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/left.java @@ -0,0 +1,3 @@ +public abstract class Artifact { + public abstract T addChild(final T child); +} diff --git a/bin/tests/scenarios/method_parameters_differ_on_final_keyword/merge.java b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/merge.java new file mode 100644 index 0000000..184ad0b --- /dev/null +++ b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/merge.java @@ -0,0 +1 @@ +public abstract class Artifact { public abstract T addChild ( T child ) ; } \ No newline at end of file diff --git a/bin/tests/scenarios/method_parameters_differ_on_final_keyword/right.java b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/right.java new file mode 100644 index 0000000..0574a7a --- /dev/null +++ b/bin/tests/scenarios/method_parameters_differ_on_final_keyword/right.java @@ -0,0 +1,3 @@ +public abstract class Artifact { + public abstract T addChild(T child); +} \ No newline at end of file diff --git a/matching_handlers/src/java/method_declaration.rs b/matching_handlers/src/java/method_declaration.rs index 350804b..a2262d7 100644 --- a/matching_handlers/src/java/method_declaration.rs +++ b/matching_handlers/src/java/method_declaration.rs @@ -54,7 +54,7 @@ fn extract_argument_types_from_formal_parameters(node: &CSTNode) -> Vec non_terminal .children .iter() - .filter(|node| node.kind() != "identifier") + .filter(|node| node.kind() != "modifiers" && node.kind() != "identifier") .fold(String::new(), |acc, cur| { format!("{} {}", acc, cur.contents()) }),