Semantic tokens: Allow for multiple line comments

This commit is contained in:
Luuk de Gram 2021-03-07 18:52:22 +01:00
parent 53c37765c0
commit a078a62a37
No known key found for this signature in database
GPG Key ID: A002B174963DBB7D

View File

@ -76,7 +76,7 @@ const Builder = struct {
fn add(self: *Builder, token: ast.TokenIndex, token_type: TokenType, token_modifiers: TokenModifiers) !void { fn add(self: *Builder, token: ast.TokenIndex, token_type: TokenType, token_modifiers: TokenModifiers) !void {
const starts = self.handle.tree.tokens.items(.start); const starts = self.handle.tree.tokens.items(.start);
const start_idx = if (self.current_token) |current_token| var start_idx = if (self.current_token) |current_token|
starts[current_token] starts[current_token]
else else
0; 0;
@ -84,7 +84,7 @@ const Builder = struct {
if (start_idx > starts[token]) if (start_idx > starts[token])
return; return;
const delta_loc = if (self.findCommentBetween(start_idx, starts[token])) |comment| blk: { const delta_loc = while (self.findCommentBetween(start_idx, starts[token])) |comment| {
const old_loc = self.handle.tree.tokenLocation(0, self.current_token orelse 0); const old_loc = self.handle.tree.tokenLocation(0, self.current_token orelse 0);
const comment_delta = offsets.tokenRelativeLocation(self.handle.tree, start_idx, comment.start, self.encoding) catch return; const comment_delta = offsets.tokenRelativeLocation(self.handle.tree, start_idx, comment.start, self.encoding) catch return;
@ -96,7 +96,7 @@ const Builder = struct {
0, 0,
}); });
break :blk offsets.tokenRelativeLocation(self.handle.tree, comment.start, starts[token], self.encoding) catch return; start_idx = comment.start;
} else offsets.tokenRelativeLocation(self.handle.tree, start_idx, starts[token], self.encoding) catch return; } else offsets.tokenRelativeLocation(self.handle.tree, start_idx, starts[token], self.encoding) catch return;
try self.arr.appendSlice(&[_]u32{ try self.arr.appendSlice(&[_]u32{