Skip to content

Commit 43db15f

Browse files
committed
Store last byte in SourceRef and allow removing green_tree
Exactly what information we want to prune in the final implementation is not determined, but `green_tree` is probably part of it.
1 parent cfc1e96 commit 43db15f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/syntax_graph.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,15 @@ end
304304
struct SourceRef
305305
file::SourceFile
306306
first_byte::Int
307-
# TODO: Do we need the green node, or would last_byte suffice?
308-
green_tree::JuliaSyntax.GreenNode
307+
last_byte::Int
308+
green_tree::Union{Nothing, JuliaSyntax.GreenNode}
309309
end
310310

311+
SourceRef(file::SourceFile, first_byte::Int, green_tree::Union{Nothing, JuliaSyntax.GreenNode}) =
312+
SourceRef(file, first_byte, first_byte + span(green_tree) - 1, green_tree)
313+
311314
JuliaSyntax.sourcefile(src::SourceRef) = src.file
312-
JuliaSyntax.byte_range(src::SourceRef) = src.first_byte:(src.first_byte + span(src.green_tree) - 1)
315+
JuliaSyntax.byte_range(src::SourceRef) = src.first_byte:src.last_byte
313316

314317
# TODO: Adding these methods to support LineNumberNode is kind of hacky but we
315318
# can remove these after JuliaLowering becomes self-bootstrapping for macros

0 commit comments

Comments
 (0)