Skip to content

Commit 1bfae9d

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 356d61a commit 1bfae9d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/syntax_graph.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,15 @@ end
318318
struct SourceRef
319319
file::SourceFile
320320
first_byte::Int
321-
# TODO: Do we need the green node, or would last_byte suffice?
322-
green_tree::JuliaSyntax.GreenNode
321+
last_byte::Int
322+
green_tree::Union{Nothing, JuliaSyntax.GreenNode}
323323
end
324324

325+
SourceRef(file::SourceFile, first_byte::Int, green_tree::Union{Nothing, JuliaSyntax.GreenNode}) =
326+
SourceRef(file, first_byte, first_byte + span(green_tree) - 1, green_tree)
327+
325328
JuliaSyntax.sourcefile(src::SourceRef) = src.file
326-
JuliaSyntax.byte_range(src::SourceRef) = src.first_byte:(src.first_byte + span(src.green_tree) - 1)
329+
JuliaSyntax.byte_range(src::SourceRef) = src.first_byte:src.last_byte
327330

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

0 commit comments

Comments
 (0)