This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 8fe9b2754de381e988977ecaa26039848ff55b1e
Author: Sebastian Rühl <sru...@apache.org>
AuthorDate: Tue Sep 9 09:41:58 2025 +0200

    fix(codegen): we should use the right context now for the comment
---
 .../codegenerator/language/mspec/parser/MessageFormatListener.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
 
b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
index 0edc7e78f8..38ca85049f 100644
--- 
a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
+++ 
b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
@@ -96,8 +96,11 @@ public class MessageFormatListener extends MSpecBaseListener 
implements LazyType
 
     // Helper: Attach comment if directly above or on the same line
     private String consumePendingComment(ParserRuleContext ctx) {
-        ctx = ctx.getParent(); // TODO: this is because of the stupid bracket 
which is considered a previous token... figure out a smart way
         Token startToken = ctx.getStart();
+        while (startToken.getType() != MSpecLexer.LBRACKET) { // Bit hacky 
workaround to assume start is always the bracket but should work
+            ctx = ctx.getParent();          // Switch to parent context...
+            startToken = ctx.getStart();    // ...and use this as start
+        }
 
         List<Token> frontComments = new LinkedList<>();
         int tokenIndex = startToken.getTokenIndex();

Reply via email to