@@ -112,7 +112,7 @@ func (c *cc) convertCreate_table_stmtContext(n *parser.Create_table_stmtContext)
112
112
stmt := & ast.CreateTableStmt {
113
113
Name : parseTableName (n ),
114
114
IfNotExists : n .EXISTS_ () != nil ,
115
- Comment : comment (tokenStream , n , false ),
115
+ Comment : comment (tokenStream , n . OPEN_PAR (). GetSymbol () ),
116
116
}
117
117
118
118
for _ , idef := range n .AllColumn_def () {
@@ -126,27 +126,22 @@ func (c *cc) convertCreate_table_stmtContext(n *parser.Create_table_stmtContext)
126
126
Colname : identifier (def .Column_name ().GetText ()),
127
127
IsNotNull : hasNotNullConstraint (def .AllColumn_constraint ()),
128
128
TypeName : & ast.TypeName {Name : typeName },
129
- Comment : comment (tokenStream , def , true ),
129
+ Comment : comment (tokenStream , def . GetStop () ),
130
130
})
131
131
132
132
}
133
133
}
134
134
return stmt
135
135
}
136
136
137
- // comment returns the comment associated with the given context. The parameter right indicates whether the comment is
138
- // to the right or to the left of the context.
139
- func comment (tokenStream * antlr.CommonTokenStream , ctx antlr.ParserRuleContext , right bool ) string {
137
+ // comment returns the comment associated with the given context.
138
+ func comment (tokenStream * antlr.CommonTokenStream , from antlr.Token ) string {
140
139
var (
141
140
hiddenTokens []antlr.Token
142
141
comment string
143
142
)
144
143
145
- if right {
146
- hiddenTokens = tokenStream .GetHiddenTokensToRight (ctx .GetStop ().GetTokenIndex ()+ 1 , antlr .TokenHiddenChannel )
147
- } else {
148
- hiddenTokens = tokenStream .GetHiddenTokensToLeft (ctx .GetStart ().GetTokenIndex (), antlr .TokenHiddenChannel )
149
- }
144
+ hiddenTokens = tokenStream .GetHiddenTokensToRight (from .GetTokenIndex ()+ 1 , antlr .TokenHiddenChannel )
150
145
151
146
for _ , token := range hiddenTokens {
152
147
// Filter for single-line comments
0 commit comments