Skip to content

Commit

Permalink
Extracted method for future extension
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Jul 2, 2024
1 parent 0f935a1 commit bfa0559
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/codetracker/BlockTrackerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ private History.HistoryInfo<Block> blameReturn(Block startBlock) {
Collections.reverse(history);
for (History.HistoryInfo<Block> historyInfo : history) {
for (Change change : historyInfo.getChangeList()) {
if (startBlock.isClosingCurlyBracket() && startBlock.getComposite() instanceof CompositeStatementObject) {
if (startBlock.isClosingCurlyBracket()) {
if (change instanceof Introduced) {
return historyInfo;
}
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/org/codetracker/util/AbstractCodeElementLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import gr.uom.java.xmi.UMLClass;
import gr.uom.java.xmi.UMLModel;
import gr.uom.java.xmi.UMLOperation;
import gr.uom.java.xmi.decomposition.CompositeStatementObject;

public abstract class AbstractCodeElementLocator {
protected final String commitId;
Expand Down Expand Up @@ -165,9 +166,7 @@ protected CodeElement locateWithName(Version version, UMLModel umlModel) throws
}
Block block = method.findBlock(this::blockPredicate);
if (block != null) {
if (block.getLocation().getEndLine() == lineNumber) {
block.setClosingCurlyBracket(true);
}
checkClosingBracket(block);
return block;
}
}
Expand All @@ -180,9 +179,7 @@ protected CodeElement locateWithoutName(Version version, UMLModel umlModel) thro
if (method != null) {
Block block = method.findBlockWithoutName(this::blockPredicate);
if (block != null) {
if (block.getLocation().getEndLine() == lineNumber) {
block.setClosingCurlyBracket(true);
}
checkClosingBracket(block);
return block;
}
Attribute attribute = getAttribute(umlModel, version, filePath, this::attributePredicateWithoutName);
Expand All @@ -195,9 +192,7 @@ protected CodeElement locateWithoutName(Version version, UMLModel umlModel) thro
if (attribute != null) {
Block block = attribute.findBlockWithoutName(this::blockPredicate);
if (block != null) {
if (block.getLocation().getEndLine() == lineNumber) {
block.setClosingCurlyBracket(true);
}
checkClosingBracket(block);
return block;
}
return attribute;
Expand All @@ -208,4 +203,10 @@ protected CodeElement locateWithoutName(Version version, UMLModel umlModel) thro
}
throw new CodeElementNotFoundException(filePath, name, lineNumber);
}

private void checkClosingBracket(Block block) {
if (block.getLocation().getEndLine() == lineNumber && block.getComposite() instanceof CompositeStatementObject) {
block.setClosingCurlyBracket(true);
}
}
}

0 comments on commit bfa0559

Please sign in to comment.