@@ -174,10 +174,13 @@ function interpolate_literal(node::SyntaxNode, val)
174
174
SyntaxNode (node. source, node. raw, node. position, node. parent, true , val)
175
175
end
176
176
177
- function _show_syntax_node (io, current_filename, node:: AbstractSyntaxNode , indent)
177
+ function _show_syntax_node (io, current_filename, node:: AbstractSyntaxNode , indent, show_byte_offsets )
178
178
fname = node. source. filename
179
179
line, col = source_location (node. source, node. position)
180
- posstr = " $(lpad (line, 4 )) :$(rpad (col,3 )) │$(lpad (first_byte (node),6 )) :$(rpad (last_byte (node),6 )) │"
180
+ posstr = " $(lpad (line, 4 )) :$(rpad (col,3 )) │"
181
+ if show_byte_offsets
182
+ posstr *= " $(lpad (first_byte (node),6 )) :$(rpad (last_byte (node),6 )) │"
183
+ end
181
184
val = node. val
182
185
nodestr = haschildren (node) ? " [$(untokenize (head (node))) ]" :
183
186
isa (val, Symbol) ? string (val) : repr (val)
@@ -192,7 +195,7 @@ function _show_syntax_node(io, current_filename, node::AbstractSyntaxNode, inden
192
195
if haschildren (node)
193
196
new_indent = indent* " "
194
197
for n in children (node)
195
- _show_syntax_node (io, current_filename, n, new_indent)
198
+ _show_syntax_node (io, current_filename, n, new_indent, show_byte_offsets )
196
199
end
197
200
end
198
201
end
@@ -217,9 +220,9 @@ function _show_syntax_node_sexpr(io, node::AbstractSyntaxNode)
217
220
end
218
221
end
219
222
220
- function Base. show (io:: IO , :: MIME"text/plain" , node:: AbstractSyntaxNode )
221
- println (io, " line:col│ byte_range │ tree │ file_name" )
222
- _show_syntax_node (io, Ref {Union{Nothing,String}} (nothing ), node, " " )
223
+ function Base. show (io:: IO , :: MIME"text/plain" , node:: AbstractSyntaxNode ; show_byte_offsets = false )
224
+ println (io, " line:col│$(show_byte_offsets ? " byte_range │" : " " ) tree │ file_name" )
225
+ _show_syntax_node (io, Ref {Union{Nothing,String}} (nothing ), node, " " , show_byte_offsets )
223
226
end
224
227
225
228
function Base. show (io:: IO , :: MIME"text/x.sexpression" , node:: AbstractSyntaxNode )
0 commit comments