use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class CreateCommonChangeBlocksTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
BehavioralBlackboard blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
groupedFile = new GroupedFile("test.java", null, null, null);
groupedFiles.add(groupedFile);
createCommonChangeBlocks = new CreateCommonChangeBlocks(blackboard);
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class CreateSolutionEntriesTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
groupedFile = new GroupedFile("test.java", new ProgrammingExerciseTestCase(), null, null);
groupedFiles.add(groupedFile);
createSolutionEntries = new CreateSolutionEntries(blackboard);
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class ExtractChangedLinesTest method initBlackboard.
@BeforeEach
public void initBlackboard() {
BehavioralBlackboard blackboard = new BehavioralBlackboard(null, null, null);
var groupedFiles = new ArrayList<GroupedFile>();
blackboard.setGroupedFiles(groupedFiles);
gitDiffEntries = new HashSet<>();
groupedFile = new GroupedFile("test.java", null, gitDiffEntries, null);
groupedFiles.add(groupedFile);
extractChangedLines = new ExtractChangedLines(blackboard);
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class AddUncoveredLinesAsPotentialCodeBlocks method executeAction.
@Override
public boolean executeAction() {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
var newChangeBlocks = new TreeSet<ChangeBlock>();
for (ChangeBlock commonChange : groupedFile.getCommonChanges()) {
var firstLine = commonChange.getLines().first();
var potentialPrefix = getPotentialPrefix(firstLine, groupedFile.getFileContent());
if (potentialPrefix != null) {
newChangeBlocks.add(potentialPrefix);
}
var lastLine = commonChange.getLines().last();
var potentialPostfix = getPotentialPostfix(lastLine, groupedFile.getFileContent());
if (potentialPostfix != null) {
newChangeBlocks.add(potentialPostfix);
}
}
if (!newChangeBlocks.isEmpty()) {
groupedFile.getCommonChanges().addAll(newChangeBlocks);
didChanges = true;
}
}
return didChanges;
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class CombineChangeBlocks method executeAction.
@Override
public boolean executeAction() throws BehavioralSolutionEntryGenerationException {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
while (true) {
var currentChangeBlocks = new ArrayList<>(groupedFile.getCommonChanges());
var newChangeBlocks = new ArrayList<GroupedFile.ChangeBlock>();
for (int i = 0; i < currentChangeBlocks.size(); i++) {
var currentChangeBlock = currentChangeBlocks.get(i);
// If this is not the last change block check if it can be merged with the next change block
if (i < currentChangeBlocks.size() - 1) {
var nextChangeBlock = currentChangeBlocks.get(i + 1);
if (currentChangeBlock.intersectsOrTouches(nextChangeBlock)) {
var lines = new TreeSet<>(currentChangeBlock.getLines());
lines.addAll(nextChangeBlock.getLines());
newChangeBlocks.add(new GroupedFile.ChangeBlock(lines));
// Skip the next change block, as it has already been processed
i++;
continue;
}
}
newChangeBlocks.add(currentChangeBlock);
}
if (!newChangeBlocks.equals(currentChangeBlocks)) {
groupedFile.setCommonChanges(newChangeBlocks);
didChanges = true;
} else {
break;
}
}
}
return didChanges;
}
Aggregations