Skip to content

Commit

Permalink
Fix annotation by making the List of comments mutable and add a test …
Browse files Browse the repository at this point in the history
…for annotation
  • Loading branch information
Hallomann93 authored and b-fein committed Dec 31, 2024
1 parent 7d45c3a commit d3a4782
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private CommentMetadataList convertComments(final Map<RawBlockId, RawComment> co
comment.text()
);
})
.toList();
.collect(Collectors.toCollection(ArrayList::new));
return new CommentMetadataList(commentMetadata);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,21 @@ private String formatHintText(String hintText) {
hintText = hintText.replace("[LEQ]","<");
hintText = hintText.replace("[GEQ]",">");
hintText = hintText.replace("[EQ]","=");
hintText = hintText.replace("[b]", "");
hintText = hintText.replace("[/b]", "");
hintText = hintText.replace("[/bc]","");
hintText = hintText.replace("[IF]", IssueTranslator.getInstance().getInfo("if"));
hintText = hintText.replace("[ELSE]", IssueTranslator.getInstance().getInfo("else"));
//if there is a linebreak followed by a whitespace, the whitespace should be removed for styling reasons
hintText = hintText.replace("[newLine] ", "\n");
hintText = hintText.replace("[newLine]", "\n");
hintText = hintText.replace("[","");
hintText = hintText.replace(" v]","");
hintText = hintText.replace(" ]","");
hintText = hintText.replace(" v)"," )");
hintText = hintText.replace("\"", "\\\"");

// hintText = hintText.replace("\"", "\\\"");

return hintText;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,41 @@
package de.uni_passau.fim.se2.litterbox.utils;

import de.uni_passau.fim.se2.litterbox.JsonTest;
import de.uni_passau.fim.se2.litterbox.analytics.Issue;
import de.uni_passau.fim.se2.litterbox.analytics.bugpattern.ForeverInsideLoop;
import de.uni_passau.fim.se2.litterbox.ast.ParsingException;
import de.uni_passau.fim.se2.litterbox.ast.model.Program;
import de.uni_passau.fim.se2.litterbox.jsoncreation.JSONFileCreator;
import de.uni_passau.fim.se2.litterbox.report.CommentGenerator;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;

class JSONCreate implements JsonTest {

@AfterAll
static void cleanUp() throws IOException {
Files.delete(Path.of("manipulatedBroadcast_annotated.json"));
Files.delete(Path.of("foreverInLoop_annotated.json"));
}

@Test
public void createJSON() throws ParsingException, IOException {
Program test = getAST("./src/test/fixtures/stmtParser/manipulatedBroadcast.json");
JSONFileCreator.writeJsonFromProgram(test, "_annotated");
}

@Test
public void createAnnotatedJSON() throws ParsingException, IOException {
Program prog = getAST("./src/test/fixtures/bugpattern/foreverInLoop.json");
ForeverInsideLoop fil = new ForeverInsideLoop();
Set<Issue> issues = fil.check(prog);
CommentGenerator gen = new CommentGenerator();
gen.generateReport(prog, issues);
JSONFileCreator.writeJsonFromProgram(prog, "_annotated");
}
}

0 comments on commit d3a4782

Please sign in to comment.