Merge pull request #351 from leecannon/moved_backwards
Handle tag moved backwards without logging
This commit is contained in:
commit
3feba5ec0b
@ -68,15 +68,10 @@ 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 tree = self.handle.tree;
|
const tree = self.handle.tree;
|
||||||
const starts = tree.tokens.items(.start);
|
const starts = tree.tokens.items(.start);
|
||||||
const tags = tree.tokens.items(.tag);
|
|
||||||
const next_start = starts[token];
|
const next_start = starts[token];
|
||||||
|
|
||||||
if (next_start < self.previous_position) {
|
if (next_start < self.previous_position) {
|
||||||
log.err(
|
return error.MovedBackwards;
|
||||||
"Moved backwards from {} at position {} to {} at {}.",
|
|
||||||
.{ tags[self.previous_token orelse 0], self.previous_position, tags[token], next_start },
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.previous_token) |prev| {
|
if (self.previous_token) |prev| {
|
||||||
@ -259,6 +254,7 @@ const WriteTokensError = error{
|
|||||||
Utf8OverlongEncoding,
|
Utf8OverlongEncoding,
|
||||||
Utf8EncodesSurrogateHalf,
|
Utf8EncodesSurrogateHalf,
|
||||||
Utf8CodepointTooLarge,
|
Utf8CodepointTooLarge,
|
||||||
|
MovedBackwards,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn writeNodeTokens(
|
fn writeNodeTokens(
|
||||||
@ -1048,7 +1044,10 @@ pub fn writeAllSemanticTokens(
|
|||||||
// reverse the ast from the root declarations
|
// reverse the ast from the root declarations
|
||||||
var buf: [2]ast.Node.Index = undefined;
|
var buf: [2]ast.Node.Index = undefined;
|
||||||
for (declMembers(handle.tree, 0, &buf)) |child| {
|
for (declMembers(handle.tree, 0, &buf)) |child| {
|
||||||
try writeNodeTokens(&builder, arena, store, child);
|
writeNodeTokens(&builder, arena, store, child) catch |err| switch (err) {
|
||||||
|
error.MovedBackwards => break,
|
||||||
|
else => |e| return e,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
try builder.finish();
|
try builder.finish();
|
||||||
return builder.toOwnedSlice();
|
return builder.toOwnedSlice();
|
||||||
|
@ -100,7 +100,7 @@ const Server = struct {
|
|||||||
|
|
||||||
fn shutdown(self: *Server) void {
|
fn shutdown(self: *Server) void {
|
||||||
self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
|
self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
|
||||||
waitNoError(self.process) catch |err| @panic("Server error");
|
waitNoError(self.process) catch @panic("Server error");
|
||||||
self.process.deinit();
|
self.process.deinit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user