@@ -14,12 +14,13 @@ pub const TrigramStore = @This();
1414pub const Trigram = [3 ]u8 ;
1515
1616pub const NameSlice = struct { start : u32 , end : u32 };
17+ pub const Loc = struct { start : u32 , end : u32 };
1718
1819pub const Declaration = struct {
1920 pub const Index = enum (u32 ) { _ };
2021
2122 name : NameSlice ,
22- range : offsets.Range ,
23+ loc : Loc ,
2324};
2425
2526has_filter : bool ,
@@ -31,7 +32,6 @@ names: std.ArrayListUnmanaged(u8),
3132pub fn init (
3233 allocator : std.mem.Allocator ,
3334 tree : Ast ,
34- encoding : offsets.Encoding ,
3535) error {OutOfMemory }! TrigramStore {
3636 var store : TrigramStore = .{
3737 .has_filter = false ,
@@ -46,7 +46,6 @@ pub fn init(
4646 allocator : std.mem.Allocator ,
4747 store : * TrigramStore ,
4848 in_function : bool ,
49- encoding : offsets.Encoding ,
5049
5150 const Error = error {OutOfMemory };
5251 fn callback (context : * @This (), cb_tree : Ast , node : Ast .Node .Index ) Error ! void {
@@ -84,10 +83,12 @@ pub fn init(
8483 const name = cb_tree .tokenSlice (token );
8584
8685 if (name .len >= 3 ) {
86+ const loc = offsets .tokenToLoc (cb_tree , token );
87+
8788 try context .store .appendDeclaration (
8889 context .allocator ,
8990 name ,
90- offsets . tokenToRange ( cb_tree , token , context . encoding ) ,
91+ .{ . start = @intCast ( loc . start ), . end = @intCast ( loc . end ) } ,
9192 );
9293 }
9394 }
@@ -104,7 +105,6 @@ pub fn init(
104105 .allocator = allocator ,
105106 .store = & store ,
106107 .in_function = false ,
107- .encoding = encoding ,
108108 };
109109 try ast .iterateChildren (tree , .root , & context , Context .Error , Context .callback );
110110
@@ -162,7 +162,7 @@ fn appendDeclaration(
162162 store : * TrigramStore ,
163163 allocator : std.mem.Allocator ,
164164 name : []const u8 ,
165- range : offsets.Range ,
165+ loc : Loc ,
166166) error {OutOfMemory }! void {
167167 assert (name .len >= 3 );
168168
@@ -177,7 +177,7 @@ fn appendDeclaration(
177177
178178 try store .declarations .append (allocator , .{
179179 .name = name_slice ,
180- .range = range ,
180+ .loc = loc ,
181181 });
182182
183183 for (0.. name .len - 2 ) | index | {
0 commit comments