line number change wip
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ public class FixedViolationHunkParser extends FixedViolationParser {
|
||||
|
||||
//Filter out the modify actions, which are not in the DiffEntry hunks.
|
||||
HunkActionFilter hunkFilter = new HunkActionFilter();
|
||||
List<DiffEntryHunk> selectedPatchHunks = hunkFilter.filterActionsByModifiedRange2(diffentryHunks, actionSets, revFile, prevFile);
|
||||
List<DiffEntryHunk> selectedPatchHunks = hunkFilter.filterActionsByLineNumber4C(diffentryHunks, actionSets, revFile, prevFile);
|
||||
|
||||
for (DiffEntryHunk patchHunk : selectedPatchHunks) {
|
||||
List<HierarchicalActionSet> hunkActionSets = patchHunk.getActionSets();
|
||||
|
||||
@@ -28,7 +28,8 @@ public class TestHunkParser {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// input data
|
||||
final List<MessageFile> msgFiles = getMessageFiles(Configuration.GUM_TREE_INPUT);
|
||||
String pjName = "linux";
|
||||
final List<MessageFile> msgFiles = getMessageFiles(Configuration.GUM_TREE_INPUT +pjName +"/");
|
||||
System.out.println(msgFiles.size());
|
||||
|
||||
// output path
|
||||
@@ -38,11 +39,11 @@ public class TestHunkParser {
|
||||
final String editScriptSizesFilePath = Configuration.EDITSCRIPT_SIZES_FILE;
|
||||
final String alarmTypesFilePath = Configuration.ALARM_TYPES_FILE;
|
||||
|
||||
FileHelper.deleteDirectory(editScriptsFilePath);
|
||||
FileHelper.deleteDirectory(patchesSourceCodeFilePath);
|
||||
FileHelper.deleteDirectory(buggyTokensFilePath);
|
||||
FileHelper.deleteDirectory(editScriptSizesFilePath);
|
||||
FileHelper.deleteDirectory(alarmTypesFilePath);
|
||||
// FileHelper.deleteDirectory(editScriptsFilePath);
|
||||
// FileHelper.deleteDirectory(patchesSourceCodeFilePath);
|
||||
// FileHelper.deleteDirectory(buggyTokensFilePath);
|
||||
// FileHelper.deleteDirectory(editScriptSizesFilePath);
|
||||
// FileHelper.deleteDirectory(alarmTypesFilePath);
|
||||
|
||||
StringBuilder astEditScripts = new StringBuilder();
|
||||
StringBuilder tokens = new StringBuilder();
|
||||
@@ -120,7 +121,7 @@ public class TestHunkParser {
|
||||
List<MessageFile> msgFiles = new ArrayList<>();
|
||||
|
||||
for (File revFile : revFiles) {
|
||||
if (revFile.getName().endsWith(".java")) {
|
||||
// if (revFile.getName().endsWith(".java")) {
|
||||
String fileName = revFile.getName();
|
||||
File prevFile = new File(gumTreeInput + "prevFiles/prev_" + fileName);// previous file
|
||||
fileName = fileName.replace(".java", ".txt");
|
||||
@@ -129,7 +130,7 @@ public class TestHunkParser {
|
||||
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile);
|
||||
msgFile.setPositionFile(positionFile);
|
||||
msgFiles.add(msgFile);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
return msgFiles;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AkkaParser2 {
|
||||
|
||||
|
||||
|
||||
String pjName = "linux-stable";
|
||||
String pjName = "linux";
|
||||
// String rootPath = "/Volumes/data/bugStudy/";
|
||||
// String DATASET_FILE_PATH = rootPath + "/dataset/GumTreeInput/" + pjName;
|
||||
// String GIT_REPOSITORY_PATH = "/Users/anilkoyuncu/bugLocalizationStudy/irblsensitivity/data/" + pjPath + "/" + pjName + "/gitrepo/.git";
|
||||
|
||||
@@ -3,13 +3,13 @@ package edu.lu.uni.serval.config;
|
||||
public class Configuration {
|
||||
|
||||
public static final long SECONDS_TO_WAIT = 900L;
|
||||
|
||||
|
||||
// public static String ROOT_PATH = "/Volumes/data/bugStudy/dataset/"; // The root path of all output data.
|
||||
public static String ROOT_PATH = "/Users/anilkoyuncu/bugStudy/dataset/"; // The root path of all output data.
|
||||
|
||||
public static int HUNK_SIZE = 10; // The limitation of source code lines of each DiffEntry, which will be selected as training data.
|
||||
public static final String BUGGY_TREE_SIGNAL = "BUGGY_TREE###"; // The starting signal of the tree of buggy source code .
|
||||
public static final String PATCH_SIGNAL = "PATCH###"; // The starting signal of each patch.
|
||||
public static final String PATCH_SIGNAL = "PATCH###"; // Th starting signal of each patch.
|
||||
|
||||
// input path of GumTree. (i.e., Fix patterns parser)
|
||||
public static final String GUM_TREE_INPUT = ROOT_PATH + "GumTreeInput/";// Buggy version file VS. Fixing version file, (DiffEntry File)
|
||||
|
||||
@@ -20,8 +20,8 @@ public class HierarchicalRegrouperForC {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GumTreeComparer com = new GumTreeComparer();
|
||||
File cFile1 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/prevFiles/prev_7779c5_545624_drivers#gpu#drm#drm_dp_helper.c");
|
||||
File cFile2 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/revFiles/7779c5_545624_drivers#gpu#drm#drm_dp_helper.c");
|
||||
File cFile1 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/prevFiles/prev_0a3d00_b404bc_drivers#pci#iov.c");
|
||||
File cFile2 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/revFiles/0a3d00_b404bc_drivers#pci#iov.c");
|
||||
List<Action> action = com.compareTwoFilesWithGumTreeForCCode(cFile1, cFile2);
|
||||
List<HierarchicalActionSet> actionSet = new HierarchicalRegrouperForC().regroupGumTreeResults(action);
|
||||
System.out.println(actionSet);
|
||||
@@ -241,9 +241,10 @@ public class HierarchicalRegrouperForC {
|
||||
|
||||
private boolean isStatement(ITree tree) {
|
||||
int nodeType = tree.getType();
|
||||
if (nodeType == 280002 || nodeType == 280001 || nodeType == 310200 || nodeType == 280100
|
||||
|| nodeType == 300100 || nodeType == 280003 || nodeType == 310100 || nodeType == 310300
|
||||
|| 260300 == nodeType || nodeType == 460000) {// TODO
|
||||
// if (nodeType == 280002 || nodeType == 280001 || nodeType == 310200 || nodeType == 280100
|
||||
// || nodeType == 300100 || nodeType == 280003 || nodeType == 310100 || nodeType == 310300
|
||||
// || 260300 == nodeType || nodeType == 460000) {// TODO
|
||||
if(nodeType == 460000){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -351,7 +351,53 @@ public class HunkActionFilter {
|
||||
}
|
||||
return selectedViolations;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<DiffEntryHunk> filterActionsByLineNumber4C(List<DiffEntryHunk> diffentryHunks,
|
||||
List<HierarchicalActionSet> actionSets, File revFile, File prevFile) {
|
||||
|
||||
List<DiffEntryHunk> selectedViolations = new ArrayList<>();
|
||||
|
||||
|
||||
for (DiffEntryHunk diffentryHunk : diffentryHunks) {
|
||||
// int violationEndLine = violationStartLine + diffentryHunk.getBugRange();
|
||||
int bugHunkStartLine = diffentryHunk.getBugLineStartNum();
|
||||
int bugHunkEndLine = bugHunkStartLine + diffentryHunk.getBugRange() - 1;
|
||||
int fixHunkStartLine = diffentryHunk.getFixLineStartNum();
|
||||
int fixHunkEndLine = fixHunkStartLine + diffentryHunk.getFixedHunkSize() - 1;
|
||||
|
||||
for (HierarchicalActionSet actionSet : actionSets) {
|
||||
int actionBugStartLine = actionSet.getBugStartLineNum();
|
||||
// if (actionBugStartLine == 0) {
|
||||
// actionBugStartLine = setLineNumbers(actionSet, prevUnit, revUnit);
|
||||
// }
|
||||
int actionBugEndLine = actionSet.getBugEndLineNum();
|
||||
int actionFixStartLine = actionSet.getFixStartLineNum();
|
||||
int actionFixEndLine = actionSet.getFixEndLineNum();
|
||||
|
||||
String actionStr = actionSet.getActionString();
|
||||
if (actionStr.startsWith("INS")) {
|
||||
if (fixHunkStartLine <= actionFixEndLine && fixHunkEndLine >= actionFixStartLine ) {
|
||||
if (actionBugStartLine != 0) {
|
||||
diffentryHunk.getActionSets().add(actionSet);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bugHunkStartLine <= actionBugEndLine && bugHunkEndLine >= actionBugStartLine) {
|
||||
diffentryHunk.getActionSets().add(actionSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (diffentryHunk.getActionSets().size() > 0) {
|
||||
selectedViolations.add(diffentryHunk);
|
||||
}
|
||||
}
|
||||
return selectedViolations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter out the modify actions, which are not in the DiffEntry hunks, with considering the same parent node.
|
||||
*
|
||||
@@ -440,11 +486,8 @@ public class HunkActionFilter {
|
||||
// ITree parent = null;
|
||||
// List<HierarchicalActionSet> actionSetsWithSameParent = new ArrayList<>(); //TODO
|
||||
for (HierarchicalActionSet actionSet : actionSets) {
|
||||
int actionBugStartLine = actionSet.getBugStartLineNum();
|
||||
if (actionBugStartLine == 0) {
|
||||
actionBugStartLine = setLineNumbers(actionSet, prevUnit, revUnit);
|
||||
}
|
||||
int actionBugEndLine = actionSet.getBugEndLineNum();
|
||||
int actionBugStartLine = actionSet.getStartPosition();
|
||||
int actionBugEndLine = actionSet.getLength();
|
||||
int actionFixStartLine = actionSet.getFixStartLineNum();
|
||||
int actionFixEndLine = actionSet.getFixEndLineNum();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user