Added switch to declFromIndex, fixed occasional crash
This commit is contained in:
parent
a189fa171c
commit
34adb4e22f
@ -610,6 +610,19 @@ pub fn declsFromIndexInternal(decls: *std.ArrayList(*ast.Node), tree: *ast.Tree,
|
||||
}
|
||||
}
|
||||
},
|
||||
.Switch => {
|
||||
const switch_node = node.cast(ast.Node.Switch).?;
|
||||
var case_it = switch_node.cases.iterator(0);
|
||||
while (case_it.next()) |case| {
|
||||
const case_node = case.*.cast(ast.Node.SwitchCase).?;
|
||||
if (nodeContainsSourceIndex(tree, case_node.expr, source_index)) {
|
||||
if (case_node.payload) |payload| {
|
||||
try declsFromIndexInternal(decls, tree, payload, source_index);
|
||||
}
|
||||
return try declsFromIndexInternal(decls, tree, case_node.expr, source_index);
|
||||
}
|
||||
}
|
||||
},
|
||||
// TODO: These convey no type information...
|
||||
.Payload => try decls.append(node.cast(ast.Node.Payload).?.error_symbol),
|
||||
.PointerPayload => try decls.append(node.cast(ast.Node.PointerPayload).?.value_symbol),
|
||||
|
@ -293,10 +293,11 @@ fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []cons
|
||||
{}
|
||||
|
||||
var end_idx = pos_index;
|
||||
while (end_idx < handle.document.text.len - 1 and
|
||||
while (end_idx < handle.document.text.len and
|
||||
(std.ascii.isAlNum(text[end_idx]) or text[end_idx] == '_')) : (end_idx += 1)
|
||||
{}
|
||||
|
||||
if (end_idx <= start_idx) return &[0]u8{};
|
||||
return text[start_idx + 1 .. end_idx];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user