From 2cd0b0c56b533f38f72adff96be714a276cff4bf Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Thu, 12 Sep 2024 21:02:18 -0300 Subject: [PATCH] fix: add missing object_creation_expression identifier extractor --- .../change_object_in_classe_instantiation/base.java | 9 +++++++++ .../change_object_in_classe_instantiation/left.java | 11 +++++++++++ .../change_object_in_classe_instantiation/merge.java | 1 + .../change_object_in_classe_instantiation/right.java | 9 +++++++++ parsing/src/tree_sitter_parser.rs | 8 ++++++++ 5 files changed, 38 insertions(+) create mode 100644 bin/tests/scenarios/change_object_in_classe_instantiation/base.java create mode 100644 bin/tests/scenarios/change_object_in_classe_instantiation/left.java create mode 100644 bin/tests/scenarios/change_object_in_classe_instantiation/merge.java create mode 100644 bin/tests/scenarios/change_object_in_classe_instantiation/right.java diff --git a/bin/tests/scenarios/change_object_in_classe_instantiation/base.java b/bin/tests/scenarios/change_object_in_classe_instantiation/base.java new file mode 100644 index 0000000..9eb1d41 --- /dev/null +++ b/bin/tests/scenarios/change_object_in_classe_instantiation/base.java @@ -0,0 +1,9 @@ +public class GitHubBuilder { + public GitHubBuilder withProxy(final Proxy p) { + return withConnector(new HttpConnector() { + public HttpURLConnection connect(URL url) throws IOException { + return (HttpURLConnection) url.openConnection(p); + } + }); + } +} diff --git a/bin/tests/scenarios/change_object_in_classe_instantiation/left.java b/bin/tests/scenarios/change_object_in_classe_instantiation/left.java new file mode 100644 index 0000000..186162b --- /dev/null +++ b/bin/tests/scenarios/change_object_in_classe_instantiation/left.java @@ -0,0 +1,11 @@ +public class GitHubBuilder { + private String a; + + public GitHubBuilder withProxy(final Proxy p) { + return withConnector(new HttpConnector() { + public HttpURLConnection connect(URL url) throws IOException { + return (HttpURLConnection) url.openConnection(p); + } + }); + } +} diff --git a/bin/tests/scenarios/change_object_in_classe_instantiation/merge.java b/bin/tests/scenarios/change_object_in_classe_instantiation/merge.java new file mode 100644 index 0000000..037d759 --- /dev/null +++ b/bin/tests/scenarios/change_object_in_classe_instantiation/merge.java @@ -0,0 +1 @@ +public class GitHubBuilder { private String a ; public GitHubBuilder withProxy ( final Proxy p ) { return withConnector ( new ImpatientHttpConnector ( new HttpConnector ( ) { public HttpURLConnection connect ( URL url ) throws IOException { return ( HttpURLConnection ) url . openConnection ( p ) ; } } ) ) ; } } diff --git a/bin/tests/scenarios/change_object_in_classe_instantiation/right.java b/bin/tests/scenarios/change_object_in_classe_instantiation/right.java new file mode 100644 index 0000000..5395bcd --- /dev/null +++ b/bin/tests/scenarios/change_object_in_classe_instantiation/right.java @@ -0,0 +1,9 @@ +public class GitHubBuilder { + public GitHubBuilder withProxy(final Proxy p) { + return withConnector(new ImpatientHttpConnector(new HttpConnector() { + public HttpURLConnection connect(URL url) throws IOException { + return (HttpURLConnection) url.openConnection(p); + } + })); + } +} diff --git a/parsing/src/tree_sitter_parser.rs b/parsing/src/tree_sitter_parser.rs index c3b1945..d16ee3a 100644 --- a/parsing/src/tree_sitter_parser.rs +++ b/parsing/src/tree_sitter_parser.rs @@ -90,6 +90,14 @@ impl From for ParserConfiguration { tree_sitter_java::language(), )), ); + + map.insert( + "object_creation_expression", + Box::new(TreeSitterQuery::new( + r#"(object_creation_expression (type_identifier) @type_identifier)"#, + tree_sitter_java::language(), + )), + ); map }, },