File tree Expand file tree Collapse file tree
code-generation/protocol-base-mspec
src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8787 <groupId >commons-io</groupId >
8888 <artifactId >commons-io</artifactId >
8989 </dependency >
90+ <dependency >
91+ <groupId >org.apache.commons</groupId >
92+ <artifactId >commons-lang3</artifactId >
93+ </dependency >
9094 <dependency >
9195 <groupId >org.antlr</groupId >
9296 <artifactId >antlr4-runtime</artifactId >
Original file line number Diff line number Diff line change 2323import org .antlr .v4 .runtime .RuleContext ;
2424import org .antlr .v4 .runtime .Token ;
2525import org .apache .commons .io .IOUtils ;
26+ import org .apache .commons .lang3 .StringUtils ;
2627import org .apache .plc4x .plugins .codegenerator .language .mspec .LazyTypeDefinitionConsumer ;
2728import org .apache .plc4x .plugins .codegenerator .language .mspec .MSpecBaseListener ;
2829import org .apache .plc4x .plugins .codegenerator .language .mspec .MSpecLexer ;
@@ -120,7 +121,7 @@ private String consumePendingComment(ParserRuleContext ctx) {
120121
121122 var defLine = startToken .getLine ();
122123 if (!frontComments .isEmpty () && frontComments .getFirst ().getLine () == defLine - 1 ) {
123- frontComments .reversed ().forEach (token -> comment .append (token . getText () ));
124+ frontComments .reversed ().stream (). map ( Token :: getText ). forEach (tokenText -> comment .append (tokenText ). append ( '\n' ));
124125 }
125126
126127 if (eolComment != null && eolComment .getLine () == defLine ) {
@@ -130,7 +131,12 @@ private String consumePendingComment(ParserRuleContext ctx) {
130131 if (comment .isEmpty ()) {
131132 return null ;
132133 }
133- return comment .toString ();
134+ String commentString = comment .toString ();
135+ if (StringUtils .isBlank (commentString )) {
136+ return null ;
137+ }
138+ commentString = StringUtils .stripEnd (commentString , "\n " );
139+ return commentString ;
134140 }
135141
136142 @ Override
You can’t perform that action at this time.
0 commit comments