@@ -84,31 +84,31 @@ public static MultiLineComponent processPlaceholders(String s, PlaceholderContex
8484 int symbol = 1 ;
8585 Stack <List <MultiLineComponent >> stack = new Stack <>();
8686 stack .push (GTUtil .list (MultiLineComponent .empty ()));
87- for (char c : s .toCharArray ()) {
88- if (escape || (literalEscape && c != LITERAL_ESCAPE )) {
89- if (c == ESCAPED_NEWLINE && !literalEscape ) {
90- GTUtil .getLast (stack .peek ()).appendNewline ();
91- line ++;
92- symbol = 0 ;
93- } else if (c == NEWLINE ) continue ;
94- else GTUtil .getLast (stack .peek ()).append (c );
95- } else {
96- switch (c ) {
97- case ESCAPE -> escapeNext = true ;
98- case LITERAL_ESCAPE -> literalEscape = !literalEscape ;
99- case NEWLINE -> {
87+ try {
88+ for (char c : s .toCharArray ()) {
89+ if (escape || (literalEscape && c != LITERAL_ESCAPE )) {
90+ if (c == ESCAPED_NEWLINE && !literalEscape ) {
10091 GTUtil .getLast (stack .peek ()).appendNewline ();
10192 line ++;
10293 symbol = 0 ;
103- }
104- case ARG_SEPARATOR -> {
105- if (stack .size () == 1 ) GTUtil .getLast (stack .peek ()).append (c );
106- else stack .peek ().add (MultiLineComponent .empty ());
107- }
108- case PLACEHOLDER_BEGIN -> stack .push (GTUtil .list (MultiLineComponent .empty ()));
109- case PLACEHOLDER_END -> {
110- List <MultiLineComponent > placeholder = stack .pop ();
111- try {
94+ } else if (c == NEWLINE ) continue ;
95+ else GTUtil .getLast (stack .peek ()).append (c );
96+ } else {
97+ switch (c ) {
98+ case ESCAPE -> escapeNext = true ;
99+ case LITERAL_ESCAPE -> literalEscape = !literalEscape ;
100+ case NEWLINE -> {
101+ GTUtil .getLast (stack .peek ()).appendNewline ();
102+ line ++;
103+ symbol = 0 ;
104+ }
105+ case ARG_SEPARATOR -> {
106+ if (stack .size () == 1 ) GTUtil .getLast (stack .peek ()).append (c );
107+ else stack .peek ().add (MultiLineComponent .empty ());
108+ }
109+ case PLACEHOLDER_BEGIN -> stack .push (GTUtil .list (MultiLineComponent .empty ()));
110+ case PLACEHOLDER_END -> {
111+ List <MultiLineComponent > placeholder = stack .pop ();
112112 if (stack .isEmpty ()) throw new UnexpectedBracketException ();
113113 MultiLineComponent result = processPlaceholder (placeholder , ctx );
114114 if (result .isIgnoreSpaces () || stack .size () == 1 ) {
@@ -134,19 +134,19 @@ public static MultiLineComponent processPlaceholders(String s, PlaceholderContex
134134 if (i != result .size () - 1 ) GTUtil .getLast (stack .peek ()).appendNewline ();
135135 }
136136 }
137- } catch (PlaceholderException e ) {
138- e .setLineInfo (line , symbol );
139- exceptions .add (e );
140- } catch (RuntimeException e ) {
141- exceptions .add (e );
142137 }
138+ default -> GTUtil .getLast (stack .peek ()).append (c );
143139 }
144- default -> GTUtil .getLast (stack .peek ()).append (c );
145140 }
141+ escape = escapeNext ;
142+ escapeNext = false ;
143+ symbol ++;
146144 }
147- escape = escapeNext ;
148- escapeNext = false ;
149- symbol ++;
145+ } catch (PlaceholderException e ) {
146+ e .setLineInfo (line , symbol );
147+ exceptions .add (e );
148+ } catch (RuntimeException e ) {
149+ exceptions .add (e );
150150 }
151151 if (stack .size () > 1 ) {
152152 PlaceholderException exception = new UnclosedBracketException ();
0 commit comments