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
12 changes: 11 additions & 1 deletion dt-impact-tracer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<dependency>
<groupId>com.reedoei</groupId>
<artifactId>eunomia</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand All @@ -133,6 +133,16 @@
<artifactId>jfreesvg</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-symbol-solver-core</artifactId>
<version>3.22.0</version>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -92,7 +93,7 @@ public static void main(String[] args) {
}

// TODO: Allow handling of randomize option; for now just run in fixed order
SmartRunner runner = new SmartRunner(TestFramework.junitTestFramework(), new TestInfoStore(), classpath, new HashMap<String, String>(), Paths.get("/dev/null"));
SmartRunner runner = new SmartRunner(TestFramework.junitTestFramework(), new TestInfoStore(), classpath, new LinkedHashMap<String, String>(), Paths.get("/dev/null"));
Configuration.config().setDefault("testplugin.classpath", "");

long start = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Stack;
import java.io.FileNotFoundException;
import java.util.Scanner;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.io.FileUtils;

public class FileCompare{

public static long filesCompareByLine(String str_path1, String str_path2) throws IOException {
Path path1 = Paths.get(str_path1);
Path path2 = Paths.get(str_path2);
try (BufferedReader bf1 = Files.newBufferedReader(path1);
BufferedReader bf2 = Files.newBufferedReader(path2)) {
long lineNumber = 1;
String line1 = "", line2 = "";
while ((line1 = bf1.readLine()) != null) {
line2 = bf2.readLine();
if (line2 == null || !line1.equals(line2)) {
return lineNumber;
}
lineNumber++;
}
if (bf2.readLine() == null) {
return -1;
}
else {
return lineNumber;
}
} catch (FileNotFoundException e){
System.out.println("Not Found");
return -500;
}
}

private static void tryCreateDirectory(final File theDir) {
try {
Files.createDirectory(theDir.toPath());
} catch (FileAlreadyExistsException ignored) {
// The directory must have been created in between the check above and our attempt to create it.
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public static void main(String[] args) throws IOException{

List<String> argsList = new ArrayList<String>(Arrays.asList(args));
int firstFileIndex = argsList.indexOf("-firstFile");
int secondFileIndex = argsList.indexOf("-secondFile");
String first_file = argsList.get(firstFileIndex+1);
String second_file = argsList.get(secondFileIndex+1);
File folder = new File(first_file);
File[] listOfFiles = folder.listFiles();
File theDir = new File("matchingOutput");
// if the directory does not exist, create it
tryCreateDirectory(theDir);
FileWriter output = null;
BufferedWriter writer = null;
try {
output = new FileWriter("matchingOutput" + File.separator + "nomatch", true);
writer = new BufferedWriter(output);
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
String input_file = listOfFiles[i].getName();
try {
String primary_file = first_file+File.separator+input_file;
String secondary_file = second_file+File.separator+input_file;
long x = filesCompareByLine(primary_file, secondary_file);
if (x!= -1 && x != -500) {
writer.write(input_file);
System.out.println("Files: " + input_file);
}
} catch (Exception e) {
System.out.println("File Not Found in Second List" + listOfFiles[i].getName());
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
if (writer != null) {
writer.close();
}
if (output != null) {
output.close();
}
} catch (IOException e) {
// Ignore issues during closing
}
}
/*try {
File rootFile = new File(argsList.get(inputTestList)+"sootSeqOutput/test");
Scanner fileReader = new Scanner(rootFile);
while (fileReader.hasNextLine()) {
String data = fileReader.nextLine();
}
} catch (FileNotFoundException e) {
}*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import edu.washington.cs.dt.impact.util.MethodVisitor;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.BinaryExpr;
import com.github.javaparser.ast.stmt.IfStmt;
import com.github.javaparser.ast.stmt.Statement;
import com.github.javaparser.ast.visitor.ModifierVisitor;
import com.github.javaparser.ast.visitor.Visitable;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
import com.github.javaparser.utils.CodeGenerationUtils;
import com.github.javaparser.utils.Log;
import com.github.javaparser.utils.SourceRoot;
import com.github.javaparser.ast.body.MethodDeclaration;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.io.*;
/**
* Some code that uses JavaParser.
*/

public class GeneratingAST {
public static void createAST(){
try {
String filename = "src/main/java/com/github/kevinsawicki/http/HttpRequest.java";
File sourceFile = new File(filename);
CompilationUnit compilationUnit = JavaParser.parse(sourceFile);
String package_path = filename.replace("src/main/java/", " ");
package_path = package_path.replace(".java", " ");
String[] parts = package_path.trim().split("/");
String package_name = String.join(".", parts);
MethodVisitor visitor = new MethodVisitor();
visitor.visit(compilationUnit, package_name);
} catch (FileNotFoundException e) {
}
}
public static void main(String[] args) throws FileNotFoundException{
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
int inputFileIndex = argsList.indexOf("-inputFile");
String input_file = argsList.get(inputFileIndex);
System.out.println(inputFileIndex);
System.out.println(input_file);
try {
createAST();
} catch (Exception e){

}
//System.out.println(path.toAbsolutePath());
//System.out.println(path.toRealPath());
//System.out.println(path);
}
}
Loading