From 5201e6f206a556a25a9ad03ca14514627565b287 Mon Sep 17 00:00:00 2001 From: Karoliine Holter Date: Thu, 15 Feb 2024 13:01:43 +0200 Subject: [PATCH 1/2] Read and show contexts in warnings if available --- src/main/java/api/messages/GoblintMessagesResult.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/api/messages/GoblintMessagesResult.java b/src/main/java/api/messages/GoblintMessagesResult.java index f021b3f..c025590 100644 --- a/src/main/java/api/messages/GoblintMessagesResult.java +++ b/src/main/java/api/messages/GoblintMessagesResult.java @@ -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; @@ -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 @@ -70,7 +76,8 @@ public static class Piece implements MultiPiece { */ public List convert(List 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); } From 1d360b9fdf4d47d8051ff334e97774541f2f28dc Mon Sep 17 00:00:00 2001 From: Karoliine Holter Date: Thu, 15 Feb 2024 13:31:40 +0200 Subject: [PATCH 2/2] Remove unused import --- src/main/java/api/messages/GoblintMessagesResult.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/api/messages/GoblintMessagesResult.java b/src/main/java/api/messages/GoblintMessagesResult.java index c025590..920a45e 100644 --- a/src/main/java/api/messages/GoblintMessagesResult.java +++ b/src/main/java/api/messages/GoblintMessagesResult.java @@ -4,7 +4,6 @@ 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;