Skip to content

Commit

Permalink
Fix for issue #193
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Nov 4, 2024
1 parent f35981e commit ffbb8fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
47 changes: 31 additions & 16 deletions src/main/java/org/codetracker/BlockTrackerChangeHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,16 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
if (matchedBlockInsideExtractedMethodBody.equalIdentifierIgnoringVersion(rightBlock)) {
matchedBlockFromSourceMethod = mapping.getFragment1();
Block blockBefore = Block.of((StatementObject) mapping.getFragment1(), bodyMapper.getContainer1(), parentVersion);
List<String> stringRepresentationBefore = blockBefore.getComposite().stringRepresentation();
List<String> stringRepresentationAfter = matchedBlockInsideExtractedMethodBody.getComposite().stringRepresentation();
if (!stringRepresentationBefore.equals(stringRepresentationAfter)) {
//blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
if (!blockBefore.getComposite().getString().equals(matchedBlockInsideExtractedMethodBody.getComposite().getString())) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
}
else {
if(blockBefore.differInFormatting(matchedBlockInsideExtractedMethodBody)) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE));
}
else {
blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.of(AbstractChange.Type.NO_CHANGE));
}
}
break;
}
Expand Down Expand Up @@ -299,11 +304,16 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
if (matchedBlockInsideExtractedMethodBody.equalIdentifierIgnoringVersion(rightBlock)) {
matchedBlockFromSourceMethod = mapping.getFragment1();
Block blockBefore = Block.of((StatementObject) mapping.getFragment1(), anonymousMapper.getContainer1(), parentVersion);
List<String> stringRepresentationBefore = blockBefore.getComposite().stringRepresentation();
List<String> stringRepresentationAfter = matchedBlockInsideExtractedMethodBody.getComposite().stringRepresentation();
if (!stringRepresentationBefore.equals(stringRepresentationAfter)) {
//blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
if (!blockBefore.getComposite().getString().equals(matchedBlockInsideExtractedMethodBody.getComposite().getString())) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
}
else {
if(blockBefore.differInFormatting(matchedBlockInsideExtractedMethodBody)) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE));
}
else {
blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.of(AbstractChange.Type.NO_CHANGE));
}
}
break;
}
Expand Down Expand Up @@ -363,11 +373,16 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
if (matchedBlockInsideExtractedMethodBody.equalIdentifierIgnoringVersion(rightBlock)) {
matchedBlockFromSourceMethod = mapping.getFragment1();
Block blockBefore = Block.of((StatementObject) mapping.getFragment1(), bodyMapper.getContainer1(), parentVersion);
List<String> stringRepresentationBefore = blockBefore.getComposite().stringRepresentation();
List<String> stringRepresentationAfter = matchedBlockInsideExtractedMethodBody.getComposite().stringRepresentation();
if (!stringRepresentationBefore.equals(stringRepresentationAfter)) {
//blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
if (!blockBefore.getComposite().getString().equals(matchedBlockInsideExtractedMethodBody.getComposite().getString())) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
}
else {
if(blockBefore.differInFormatting(matchedBlockInsideExtractedMethodBody)) {
addStatementChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE));
}
else {
blockChangeHistory.addChange(blockBefore, matchedBlockInsideExtractedMethodBody, ChangeFactory.of(AbstractChange.Type.NO_CHANGE));
}
}
break;
}
Expand Down Expand Up @@ -876,7 +891,7 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
Block blockAfter = Block.of((StatementObject) mapping.getFragment2(), umlOperationBodyMapper.getContainer2(), currentVersion);
if (blockAfter != null && equalOperator.test(blockAfter)) {
Block blockBefore = Block.of((StatementObject) mapping.getFragment1(), umlOperationBodyMapper.getContainer1(), parentVersion);
if (!blockBefore.getComposite().toString().equals(blockAfter.getComposite().toString())) {
if (!blockBefore.getComposite().getString().equals(blockAfter.getComposite().getString())) {
addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.BODY_CHANGE));
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/blame/blameTestWithLocalRepo3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ ec2834e43 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Roman Iva
77acd41cf src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Andrei Selkin 2016-02-16 19:22:01 +0000 315) private SortedSet<LocalizedMessage> processFile(File file) throws CheckstyleException {
fbf3f95c2 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Andrei Selkin 2016-09-21 02:52:06 +0000 316) final SortedSet<LocalizedMessage> fileMessages = new TreeSet<>();
13b7c6343 src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java (Oliver Burn 2008-11-09 09:37:27 +0000 317) try {
f1e80e4ec src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Michal Kordas 2015-08-08 04:38:41 +0000 318) final FileText theText = new FileText(file.getAbsoluteFile(), charset);
d46c2cf0e src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Andrei Selkin 2016-02-09 17:50:02 +0000 318) final FileText theText = new FileText(file.getAbsoluteFile(), charset);
b8ca6a585 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (alexkravin 2015-01-19 14:38:32 +0000 319) for (final FileSetCheck fsc : fileSetChecks) {
f1e80e4ec src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Michal Kordas 2015-08-08 04:38:41 +0000 320) fileMessages.addAll(fsc.process(file, theText));
13b7c6343 src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java (Oliver Burn 2008-11-09 09:37:27 +0000 321) }
Expand All @@ -324,7 +324,7 @@ f1e80e4ec src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Michal Ko
127f72994 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (crude 2017-10-20 17:46:57 +0000 324) log.debug("IOException occurred.", ioe);
13b7c6343 src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java (Oliver Burn 2008-11-09 09:37:27 +0000 325) fileMessages.add(new LocalizedMessage(0,
b61daf7f4 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (rnveach 2016-12-07 23:21:03 +0000 326) Definitions.CHECKSTYLE_BUNDLE, EXCEPTION_MSG,
6d5c0da42 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Michal Kordas 2015-08-09 14:41:42 +0000 327) new String[] {ioe.getMessage()}, null, getClass(), null));
d46c2cf0e src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (Andrei Selkin 2016-02-09 17:50:02 +0000 327) new String[] {ioe.getMessage()}, null, getClass(), null));
13b7c6343 src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java (Oliver Burn 2008-11-09 09:37:27 +0000 328) }
b61daf7f4 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (rnveach 2016-12-07 23:21:03 +0000 329) // -@cs[IllegalCatch] There is no other way to obey haltOnException field
b61daf7f4 src/main/java/com/puppycrawl/tools/checkstyle/Checker.java (rnveach 2016-12-07 23:21:03 +0000 330) catch (Exception ex) {
Expand Down

0 comments on commit ffbb8fd

Please sign in to comment.