minor modifications on canonical form

This commit is contained in:
Anil Koyuncu
2018-02-22 15:47:22 +01:00
parent 832fdc0bd6
commit 257a5a6443
2 changed files with 7 additions and 6 deletions
@@ -8,6 +8,7 @@ import java.util.Map;
import com.github.gumtreediff.tree.ITree; import com.github.gumtreediff.tree.ITree;
import edu.lu.uni.serval.FixPatternParser.Tokenizer;
import edu.lu.uni.serval.config.Configuration; import edu.lu.uni.serval.config.Configuration;
import edu.lu.uni.serval.diffentry.DiffEntryHunk; import edu.lu.uni.serval.diffentry.DiffEntryHunk;
import edu.lu.uni.serval.diffentry.DiffEntryReader; import edu.lu.uni.serval.diffentry.DiffEntryReader;
@@ -139,17 +140,17 @@ public class FixedViolationHunkParser extends FixedViolationParser {
} }
String patchPosition = "\n" + revFile.getName() + "\n@@ -" + bugStartLine + ", " + bugEndLine + " +" + fixStartLine + ", " + fixEndLine + "@@\n"; String patchPosition = "\n" + revFile.getName() + "\n@@ -" + bugStartLine + ", " + bugEndLine + " +" + fixStartLine + ", " + fixEndLine + "@@\n";
String info = Configuration.PATCH_SIGNAL + "\n" + patchPosition + patchHunk.getHunk() + "\nAST Diff###:\n" + getAstEditScripts(hunkActionSets, bugEndPosition, fixEndPosition) + "\n"; // String info = Configuration.PATCH_SIGNAL + "\n" + patchPosition + patchHunk.getHunk() + "\nAST Diff###:\n" + getAstEditScripts(hunkActionSets, bugEndPosition, fixEndPosition) + "\n";
//TODO uncomment the line below for more detailed gumtree input. //TODO uncomment the line below for more detailed gumtree input.
// String info = Configuration.PATCH_SIGNAL + "\n" + patchPosition + patchHunk.getHunk() + "\nAST Diff###:\n" + getAstEditScripts(hunkActionSets) + "\n"; String info = Configuration.PATCH_SIGNAL + "\n" + patchPosition + patchHunk.getHunk() + "\nAST Diff###:\n" + getAstEditScripts(hunkActionSets) + "\n";
// if (noUpdate(editScriptTokens)) { // if (noUpdate(editScriptTokens)) {
// } // }
String canonicalVariableNames = getBuggyCodeTree(patchHunk, prevFile, revFile); String canonicalVariableNames = getBuggyCodeTree(patchHunk, prevFile, revFile);
this.patchesSourceCode += info; this.patchesSourceCode += info;
this.patchesSourceCode += "\nRenamed_Variables###:" + canonicalVariableNames; this.patchesSourceCode += "\nRenamed_Variables###:\n" + canonicalVariableNames;
// this.sizes += size + "\n"; this.sizes += size + "\n";
// this.astEditScripts += astEditScripts + "\n"; this.astEditScripts += astEditScripts + "\n";
// String tokens = Tokenizer.getTokensDeepFirst(simpleTree).trim(); // String tokens = Tokenizer.getTokensDeepFirst(simpleTree).trim();
// this.tokensOfSourceCode += tokens + "\n"; // this.tokensOfSourceCode += tokens + "\n";
} }
@@ -507,7 +507,7 @@ public class SimplifyTree {
} }
private String canonicalizeVariable(String label, String typeStr) { private String canonicalizeVariable(String label, String typeStr) {
String key = label + "_" + typeStr; String key = label + ":" + typeStr;
if (canonicalVariableMap.containsKey(key)) { if (canonicalVariableMap.containsKey(key)) {
label = canonicalVariableMap.get(key); label = canonicalVariableMap.get(key);
} else { } else {