aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2023-01-22 21:52:24 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2023-01-22 21:52:24 +0100
commit827115335ff1269df28085e215b081e24596ff1d (patch)
tree9917e245f9e9b76c20cfcf1433a8e36e2f4ba0b7 /bridge
parentac2b81c3f8ab0a7af7c5078656547f1c7a9a9499 (diff)
downloadaspectj-827115335ff1269df28085e215b081e24596ff1d.tar.gz
aspectj-827115335ff1269df28085e215b081e24596ff1d.zip
Fix indentation of compilation results on the console
Whenever warnings or errors were printed via CompilationResult.toString, indirectly also using MessageUtil.renderMessage(IMessage, boolean), messages containing context info such as code snippets with carets marking erroneous tokens - see also the previous commit - prefixes like "[warning 1] warning at " were printed right in front of the code snippets. I.e., the carets marking erroneous tokens in the second line were not indented like the first line with the code snippet, leading to (simplified) output like: [warning 1] warning at after() : execution(FooBar Blah.*()) { ^^^^^^ xxx FooBar [Xlint:invalidAbsoluteTypeName] This was fixed to now correctly indent lines 2 to n according to line 1, yielding the correct output: [warning 1] warning at after() : execution(FooBar Blah.*()) { ^^^^^^ xxx FooBar [Xlint:invalidAbsoluteTypeName] Especially with longer, more complex context lines, this helps to identify the erroneous section. BTW, for one-line messages, everything of course looks like before. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'bridge')
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/MessageUtil.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
index 7ef4e92ab..4f5e6067b 100644
--- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
+++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
@@ -798,10 +798,14 @@ public class MessageUtil {
return "((IMessage) null)";
}
+ String result = message.getKind().toString();
ISourceLocation loc = message.getSourceLocation();
- String locString = (null == loc ? "" : " at " + loc);
-
- String result = message.getKind() + locString + " " + message.getMessage();
+ if (loc != null) {
+ String context = loc.getContext();
+ result += context == null || context.trim().isEmpty() ? " at " : " at\n";
+ result += loc;
+ }
+ result += " " + message.getMessage();
Throwable thrown = message.getThrown();
if (thrown != null) {