Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
kimseokjin committed Jun 11, 2020
1 parent 0541a5d commit e127e12
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ private AnnotationGraphModel buildPartitionedAnnotationGraph(Repository repo, Re
while (paths.hasNext()) {

String path = paths.next();

// For Debugging
debug = path.equals("zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java");

List<RevCommit> revs = revsWithPath.get(path);

Expand Down Expand Up @@ -201,8 +204,7 @@ private AnnotationGraphModel buildPartitionedAnnotationGraph(Repository repo, Re
System.out.println("REPLACE\n");
}

// When childIdx is the last index in hunk, update offset and increment hunk
// index
// When childIdx is the last index in hunk, update offset and increment hunk index
if (childIdx == endOfChild - 1) {
offset += (hunk.getRangeOfParent() - hunk.getRangeOfChild());

Expand All @@ -224,8 +226,7 @@ private AnnotationGraphModel buildPartitionedAnnotationGraph(Repository repo, Re

case "DELETE":
// If the last child line is in DELETE, it maps with nothing
if (childIdx == childLineList.size() - 1)
break;
if (childIdx == childLineList.size() - 1) break;

// If the begin of child belongs to both DELETE and INSERT
if (belongsToBothDELETEAndINSERT(hunkList, hunkIdx, beginOfChild)) {
Expand All @@ -241,6 +242,24 @@ private AnnotationGraphModel buildPartitionedAnnotationGraph(Repository repo, Re

break;
}

// If the begin of child belongs to both DELETE and REPLACE
// if (belongsToBothDELETEAndREPLACE(hunkList, hunkIdx, beginOfChild)) {
// // TODO implement setting offset
//
//
// childLine.setLineType(LineType.REPLACE);
// childLine.setWithinHunk(true);
// mapChildLineWithAncestors(hunk, parentLineList, childLine);
//
// hunkIdx++;
//
// if (debug) {
// System.out.println("REPLACE\n");
// }
//
// break;
// }

offset += hunk.getRangeOfParent();

Expand Down Expand Up @@ -296,6 +315,21 @@ private boolean belongsToBothDELETEAndINSERT(ArrayList<Hunk> hunkList, int currH

return false;
}

private boolean belongsToBothDELETEAndREPLACE(ArrayList<Hunk> hunkList, int currHunkIdx, int currBeginOfChild) {
int nextHunkIdx = currHunkIdx + 1;

if (nextHunkIdx < hunkList.size()) {
String nextHunkType = hunkList.get(nextHunkIdx).getHunkType();
int nextBeginOfChild = hunkList.get(nextHunkIdx).getBeginOfChild();

if (nextHunkType.equals("REPLACE") && currBeginOfChild == nextBeginOfChild) {
return true;
}
}

return false;
}

private void configureLineList(ArrayList<Line> lst, String path, RevCommit rev, String content) {
String[] contentArr = content.split("\r\n|\r|\n");
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/hgu/csee/isel/alinew/szz/trace/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<BICInfo> collectBILines(Repository repo, List<RevCommit> BFCList, An
continue;

// For Debugging
flag = (path.equals("zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java"));
// flag = (path.equals("zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java"));

if (debug || flag) {
System.out.println("\nParent Revision : " + parentRev.getName());
Expand Down Expand Up @@ -192,6 +192,8 @@ public List<BICInfo> collectBILines(Repository repo, List<RevCommit> BFCList, An
return bicList;
}
public void trace(Line line) {
// The fact that there are no ancestors means that the type of this line is INSERT
// However, due to the limit of building AG algorithm, the type of line can be CONTEXT if the line is initially inserted in commit history.
if(line.getAncestors().size() == 0) {
if (!Utils.isWhitespace(line.getContent())) {
if(flag) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hgu/csee/isel/alinew/szz/util/GitUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
public class GitUtils {

public static DiffAlgorithm diffAlgorithm = DiffAlgorithm.getAlgorithm(DiffAlgorithm.SupportedAlgorithm.MYERS);
public static RawTextComparator diffComparator = RawTextComparator.WS_IGNORE_ALL;
// public static RawTextComparator diffComparator = RawTextComparator.WS_IGNORE_ALL;
public static RawTextComparator diffComparator = RawTextComparator.WS_IGNORE_CHANGE;

public static EditList getEditListFromDiff(String file1, String file2) {
RawText rt1 = new RawText(file1.getBytes());
Expand Down

0 comments on commit e127e12

Please sign in to comment.