Skip to content

Commit

Permalink
fix(matching_handlers): Consider spread parameters for score calculat…
Browse files Browse the repository at this point in the history
…ion (#48)

In the filter condition there was a missing case in which the method
contains spread parameters, which is a different token identifier.
  • Loading branch information
jpedroh authored Mar 13, 2024
1 parent 0432f1f commit 31ea3c8
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.fosd.jdime;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;

import org.junit.BeforeClass;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class JDimeTest {
protected static File file(File parent, String child) {
File f = new File(parent, child);
assertTrue(f + " does not exist.", f.exists());

return f;
}

protected static File file(File parent, String name, String... names) {

if (names != null) {
String path = String.format("%s/%s", name, String.join("/", names));
return file(parent, path);
} else {
return file(parent, name);
}
}

protected static File file(String path) throws Exception {
URL res = JDimeTest.class.getResource(path);

assertNotNull("The file " + path + " was not found.", res);
return new File(res.toURI());
}

protected static File file(String name, String... names) throws Exception {

if (names != null) {
String path = String.format("/%s/%s", name, String.join("/", names));
return file(path);
} else {
return file("/" + name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.fosd.jdime;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;

import org.junit.BeforeClass;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class JDimeTest {
protected static File file(File parent, String child) {
File f = new File(parent, child);
assertTrue(f + " does not exist.", f.exists());

return f;
}

protected static File file(File parent, String name, String... names) {

if (names != null) {
String path = String.format("%s/%s", name, String.join("/", names));
return file(parent, path);
} else {
return file(parent, name);
}
}

protected static File file(String path) {
URL res = JDimeTest.class.getResource(path);

assertNotNull("The file " + path + " was not found.", res);

try {
return new File(res.toURI());
} catch (URISyntaxException e) {
fail(e.getMessage());
return null;
}
}

protected static File file(String name, String... names) {

if (names != null) {
String path = String.format("/%s/%s", name, String.join("/", names));
return file(path);
} else {
return file("/" + name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package de . fosd . jdime ; import java . io . File ; import java . net . URISyntaxException ; import java . net . URL ; import java . util . Arrays ; import org . junit . BeforeClass ; import static org . junit . Assert . assertNotNull ; import static org . junit . Assert . assertTrue ; import static org . junit . Assert . fail ; public class JDimeTest { protected static File file ( File parent , String child ) { File f = new File ( parent , child ) ; assertTrue ( f + " does not exist." , f . exists ( ) ) ; return f ; } protected static File file ( File parent , String name , String ... names ) { if ( names != null ) { String path = String . format ( "%s/%s" , name , String . join ( "/" , names ) ) ; return file ( parent , path ) ; } else { return file ( parent , name ) ; } } protected static File file ( String path ) { URL res = JDimeTest . class . getResource ( path ) ; assertNotNull ( "The file " + path + " was not found." , res ) ; try { return new File ( res . toURI ( ) ) ; } catch ( URISyntaxException e ) { fail ( e . getMessage ( ) ) ; return null ; } } protected static File file ( String name , String ... names ) { if ( names != null ) { String path = String . format ( "/%s/%s" , name , String . join ( "/" , names ) ) ; return file ( path ) ; } else { return file ( "/" + name ) ; } } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.fosd.jdime;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;

import org.junit.BeforeClass;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class JDimeTest {
protected static File file(File parent, String child) {
File f = new File(parent, child);
assertTrue(f + " does not exist.", f.exists());

return f;
}

protected static File file(File parent, String name, String... names) {

if (names != null) {
String path = String.format("%s/%s", name, String.join("/", names));
return file(parent, path);
} else {
return file(parent, name);
}
}

protected static File file(String path) {
URL res = JDimeTest.class.getResource(path);

assertNotNull("The file " + path + " was not found.", res);

try {
return new File(res.toURI());
} catch (URISyntaxException e) {
fail(e.getMessage());
return null;
}
}

protected static File file(String name, String... names) {

if (names != null) {
String path = String.format("/%s/%s", name, String.join("/", names));
return file(path);
} else {
return file("/" + name);
}
}
}
4 changes: 3 additions & 1 deletion matching_handlers/src/java/method_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ fn extract_argument_types_from_formal_parameters(node: &CSTNode) -> Vec<String>
CSTNode::NonTerminal(non_terminal) => non_terminal
.children
.iter()
.filter(|inner_node| inner_node.kind() == "formal_parameter")
.filter(|inner_node| {
inner_node.kind() == "formal_parameter" || inner_node.kind() == "spread_parameter"
})
.filter_map(|inner_node| match inner_node {
CSTNode::Terminal(_) => None,
CSTNode::NonTerminal(non_terminal) => Some(
Expand Down

0 comments on commit 31ea3c8

Please sign in to comment.