Skip to content

Commit 0fa9152

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 db69a7c commit 0fa9152

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
@@ -306,12 +306,15 @@ end
306306
struct SourceRef
307307
file::SourceFile
308308
first_byte::Int
309-
# TODO: Do we need the green node, or would last_byte suffice?
310-
green_tree::JuliaSyntax.GreenNode
309+
last_byte::Int
310+
green_tree::Union{Nothing, JuliaSyntax.GreenNode}
311311
end
312312

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

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

0 commit comments

Comments
 (0)