Skip to content

Commit

Permalink
Read and show contexts in warnings if available
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Feb 15, 2024
1 parent 80651da commit 5201e6f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/api/messages/GoblintMessagesResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
import com.ibm.wala.util.collections.Pair;
import magpiebridge.core.AnalysisResult;
import org.thymeleaf.context.IContext;

import java.io.File;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -58,6 +59,11 @@ public interface MultiPiece {
public static class Piece implements MultiPiece {
private String text;
private GoblintLocation loc;
private context context;

public static class context {
private Integer tag;
}

/**
* Converts the Single (Piece type of) Goblint messages from the
Expand All @@ -70,7 +76,8 @@ public static class Piece implements MultiPiece {
*/
public List<AnalysisResult> convert(List<Tag> tags, String severity, boolean explode) {
GoblintPosition pos = getLocation(loc);
String msg = joinTags(tags) + " " + text;
String ctx = context == null || context.tag == null ? "" : " in context " + context.tag;
String msg = joinTags(tags) + " " + text + ctx;
GoblintMessagesAnalysisResult result = new GoblintMessagesAnalysisResult(pos, msg, severity);
return List.of(result);
}
Expand Down

0 comments on commit 5201e6f

Please sign in to comment.