Skip to content

Commit

Permalink
Blame test file updates after RMiner improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Sep 26, 2024
1 parent 3a59940 commit 6116e74
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 31 deletions.
44 changes: 44 additions & 0 deletions src/main/java/org/codetracker/CommentTrackerChangeHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import gr.uom.java.xmi.UMLOperation;
import gr.uom.java.xmi.VariableDeclarationContainer;
import gr.uom.java.xmi.LocationInfo.CodeElementType;
import gr.uom.java.xmi.UMLAnonymousClass;
import gr.uom.java.xmi.UMLAttribute;
import gr.uom.java.xmi.UMLClass;
import gr.uom.java.xmi.UMLComment;
Expand Down Expand Up @@ -451,6 +452,33 @@ public boolean isMatched(UMLDocumentationDiffProvider umlOperationBodyMapper, Ve
matches++;
}
}
if (umlOperationBodyMapper.getContainer1().getAnonymousClassList().size() == umlOperationBodyMapper.getContainer2().getAnonymousClassList().size()) {
for (int i=0; i<umlOperationBodyMapper.getContainer2().getAnonymousClassList().size(); i++) {
UMLAnonymousClass anonymous2 = umlOperationBodyMapper.getContainer2().getAnonymousClassList().get(i);
UMLAnonymousClass anonymous1 = umlOperationBodyMapper.getContainer1().getAnonymousClassList().get(i);
if (anonymous1.getComments().size() == anonymous2.getComments().size()) {
for (int j=0; j<anonymous2.getComments().size(); j++) {
UMLComment umlComment2 = anonymous2.getComments().get(j);
UMLComment umlComment1 = anonymous1.getComments().get(j);
Comment commentAfter = Comment.of(umlComment2, umlOperationBodyMapper.getContainer2(), currentVersion);
if (commentAfter != null && equalOperator.test(commentAfter)) {
Comment commentBefore = Comment.of(umlComment1, umlOperationBodyMapper.getContainer1(), parentVersion);
if (!commentBefore.getComment().getText().equals(commentAfter.getComment().getText())) {
processChange(commentBefore, commentAfter);
}
else {
commentChangeHistory.addChange(commentBefore, commentAfter, ChangeFactory.of(AbstractChange.Type.NO_CHANGE));
}
if(matches == 0) {
elements.addFirst(commentBefore);
}
commentChangeHistory.connectRelatedNodes();
matches++;
}
}
}
}
}
if (umlOperationBodyMapper.getJavadocDiff().isPresent()) {
UMLJavadocDiff javadocDiff = umlOperationBodyMapper.getJavadocDiff().get();
Comment commentAfter = Comment.of(javadocDiff.getJavadocAfter(), umlOperationBodyMapper.getContainer2(), currentVersion);
Expand Down Expand Up @@ -545,6 +573,22 @@ private boolean isAdded(UMLDocumentationDiffProvider umlOperationBodyMapper, Ver
return true;
}
}
if (umlOperationBodyMapper.getContainer1().getAnonymousClassList().size() < umlOperationBodyMapper.getContainer2().getAnonymousClassList().size() &&
umlOperationBodyMapper.getContainer1().getAnonymousClassList().size() == 0) {
for (int i=0; i<umlOperationBodyMapper.getContainer2().getAnonymousClassList().size(); i++) {
UMLAnonymousClass anonymous2 = umlOperationBodyMapper.getContainer2().getAnonymousClassList().get(i);
for (UMLComment umlComment : anonymous2.getComments()) {
Comment commentAfter = Comment.of(umlComment, umlOperationBodyMapper.getContainer2(), currentVersion);
if (commentAfter != null && equalOperator.test(commentAfter)) {
Comment commentBefore = Comment.of(umlComment, umlOperationBodyMapper.getContainer2(), parentVersion);
commentChangeHistory.handleAdd(commentBefore, commentAfter, "new comment");
elements.addFirst(commentBefore);
commentChangeHistory.connectRelatedNodes();
return true;
}
}
}
}
UMLJavadoc javadoc = umlOperationBodyMapper.getContainer2().getJavadoc();
if (javadoc != null) {
Comment commentAfter = Comment.of(javadoc, umlOperationBodyMapper.getContainer2(), currentVersion);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/codetracker/element/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ public Comment findComment(Predicate<Comment> equalOperator) {
}
}
for (UMLAnonymousClass anonymousClass : umlOperation.getAnonymousClassList()) {
for (UMLComment umlComment : anonymousClass.getComments()) {
Comment comment = Comment.of(umlComment, this);
if (comment != null && equalOperator.test(comment)) {
return comment;
}
}
for (UMLOperation operation : anonymousClass.getOperations()) {
for (UMLComment umlComment : operation.getComments()) {
Comment comment = Comment.of(umlComment, this);
Expand Down
22 changes: 11 additions & 11 deletions src/test/resources/blame/blameTestUntilCommitZero.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,22 +671,22 @@ e426aa8b9 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter
461b012e9 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Shawn O. Pearce 2011-02-03 21:20:22 +0000 671) return stats.totalObjects;
1a6964c82 org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java (Git Development Community 2009-09-29 23:47:03 +0000 672) }
673)
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 674) /**
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 674) /**
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 675) * Returns the object ids in the pack file that was created by this writer.
f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Shawn Pearce 2015-08-14 18:13:34 +0000 676) * <p>
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 677) * This method can only be invoked after
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 678) * {@link #writePack(ProgressMonitor, ProgressMonitor, OutputStream)} has
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 679) * been invoked and completed successfully.
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 680) *
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 677) * This method can only be invoked after
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 678) * {@link #writePack(ProgressMonitor, ProgressMonitor, OutputStream)} has
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 679) * been invoked and completed successfully.
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 680) *
f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Shawn Pearce 2015-08-14 18:13:34 +0000 681) * @return set of objects in pack.
783dbf1b0 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Matthias Sohn 2017-12-19 12:39:09 +0000 682) * @throws java.io.IOException
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 683) * a cached pack cannot supply its object ids.
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 684) */
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 683) * a cached pack cannot supply its object ids.
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 684) */
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 685) public ObjectIdOwnerMap<ObjectIdOwnerMap.Entry> getObjectSet()
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 686) throws IOException {
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 687) if (!cachedPacks.isEmpty())
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 688) throw new IOException(
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 689) JGitText.get().cachedPacksPreventsListingObjects);
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 687) if (!cachedPacks.isEmpty())
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 688) throw new IOException(
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 689) JGitText.get().cachedPacksPreventsListingObjects);
690)
f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Shawn Pearce 2015-08-14 18:13:34 +0000 691) if (writeBitmaps != null) {
f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Shawn Pearce 2015-08-14 18:13:34 +0000 692) return writeBitmaps.getObjectSet();
Expand All @@ -702,7 +702,7 @@ f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 702) }
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 703) }
f9bd6c123 org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java (Shawn Pearce 2015-08-14 18:13:34 +0000 704) return r;
7fbd6588b org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-22 23:25:15 +0000 705) }
7c58f6282 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Colby Ranger 2013-01-19 00:22:10 +0000 705) }
706)
a1a8c6d77 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Shawn O. Pearce 2011-08-21 20:59:26 +0000 707) /**
a1a8c6d77 org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java (Shawn O. Pearce 2011-08-21 20:59:26 +0000 708) * Add a pack index whose contents should be excluded from the result.
Expand Down
Loading

0 comments on commit 6116e74

Please sign in to comment.