File tree Expand file tree Collapse file tree
src/main/java/net/sf/jsqlparser/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 */
1010package net .sf .jsqlparser .parser ;
1111
12+ import java .util .Set ;
13+ import java .util .TreeSet ;
14+
1215public class ASTNodeAccessImpl implements ASTNodeAccess {
1316
1417 private transient SimpleNode node ;
@@ -24,11 +27,20 @@ public void setASTNode(SimpleNode node) {
2427 }
2528
2629 public StringBuilder appendTo (StringBuilder builder ) {
30+ // don't add spaces around the following punctuation
31+ final Set <String > punctuation = new TreeSet <>(Set .of ("." , "[" , "]" ));
32+
2733 SimpleNode simpleNode = getASTNode ();
2834 Token token = simpleNode .jjtGetFirstToken ();
2935 Token lastToken = simpleNode .jjtGetLastToken ();
36+ Token prevToken = null ;
3037 while (token .next != null && token .absoluteEnd <= lastToken .absoluteEnd ) {
31- builder .append (" " ).append (token .image );
38+ if (!punctuation .contains (token .image )
39+ && (prevToken == null || !punctuation .contains (prevToken .image ))) {
40+ builder .append (" " );
41+ }
42+ builder .append (token .image );
43+ prevToken = token ;
3244 token = token .next ;
3345 }
3446 return builder ;
You can’t perform that action at this time.
0 commit comments