From c7158f762574d7612eeb3435e70c67bcf534fe3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20H=C3=A4hne?= Date: Tue, 30 Mar 2021 11:23:09 +0200 Subject: [PATCH] Remove checks again --- src/analysis.zig | 22 +--------------------- src/main.zig | 2 -- src/references.zig | 3 --- src/semantic_tokens.zig | 3 --- 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index 1f1ecbf..97578b4 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -222,8 +222,6 @@ pub fn isPascalCase(name: []const u8) bool { pub fn getDeclNameToken(tree: ast.Tree, node: ast.Node.Index) ?ast.TokenIndex { const tags = tree.nodes.items(.tag); const main_token = tree.nodes.items(.main_token)[node]; - if (tree.errors.len > 0) - return null; return switch (tags[node]) { // regular declaration names. + 1 to mut token because name comes after 'const'/'var' .local_var_decl => tree.localVarDecl(node).ast.mut_token + 1, @@ -348,8 +346,6 @@ pub fn resolveVarDeclAlias(store: *DocumentStore, arena: *std.heap.ArenaAllocato const token_tags = tree.tokens.items(.tag); const main_tokes = tree.nodes.items(.main_token); const node_tags = tree.nodes.items(.tag); - if (tree.errors.len > 0) - return null; if (varDecl(handle.tree, decl)) |var_decl| { if (var_decl.ast.init_node == 0) return null; @@ -1234,8 +1230,6 @@ pub fn getFieldAccessType( .node = undefined, .handle = handle, }); - if (handle.tree.errors.len > 0) - return null; // TODO Actually bind params here when calling functions instead of just skipping args. var bound_type_params = BoundTypeParams.init(&arena.allocator); @@ -1881,8 +1875,6 @@ fn getDocumentSymbolsInternal(allocator: *std.mem.Allocator, tree: ast.Tree, nod pub fn getDocumentSymbols(allocator: *std.mem.Allocator, tree: ast.Tree, encoding: offsets.Encoding) ![]types.DocumentSymbol { var symbols = try std.ArrayList(types.DocumentSymbol).initCapacity(allocator, tree.rootDecls().len); - if (tree.errors.len > 0) - return symbols.items; var context = GetDocumentSymbolsContext{ .symbols = &symbols, @@ -2440,12 +2432,6 @@ pub const DocumentScope = struct { error_completions: CompletionSet, enum_completions: CompletionSet, - pub const none = DocumentScope{ - .scopes = &[0]Scope{}, - .error_completions = CompletionSet{}, - .enum_completions = CompletionSet{}, - }; - pub fn debugPrint(self: DocumentScope) void { for (self.scopes) |scope| { log.debug( @@ -2509,9 +2495,6 @@ pub fn makeDocumentScope(allocator: *std.mem.Allocator, tree: ast.Tree) !Documen var error_completions = CompletionSet{}; var enum_completions = CompletionSet{}; - if (tree.errors.len > 0) - return DocumentScope.none; - errdefer { scopes.deinit(allocator); for (error_completions.entries.items) |entry| { @@ -2763,10 +2746,7 @@ fn makeScopeInternal( param.type_expr, ); } - const a = data[node_idx]; - const left = data[a.lhs]; - const right = data[a.rhs]; - // log.debug("Alive 3.2 - {}- {}- {}-{} {}- {}-{}", .{tags[node_idx], tags[a.lhs], tags[left.lhs], tags[left.rhs], tags[a.rhs], tags[right.lhs], tags[right.rhs]}); + // Visit the return type try makeScopeInternal( allocator, diff --git a/src/main.zig b/src/main.zig index bf4ff52..ef38310 100644 --- a/src/main.zig +++ b/src/main.zig @@ -356,8 +356,6 @@ fn nodeToCompletion( const node_tags = tree.nodes.items(.tag); const datas = tree.nodes.items(.data); const token_tags = tree.tokens.items(.tag); - if (tree.errors.len > 0) - return; const doc_kind: types.MarkupContent.Kind = if (client_capabilities.completion_doc_supports_md) .Markdown diff --git a/src/references.zig b/src/references.zig index d301bda..a5c2988 100644 --- a/src/references.zig +++ b/src/references.zig @@ -85,9 +85,6 @@ fn symbolReferencesInternal( const main_tokens = tree.nodes.items(.main_token); const starts = tree.tokens.items(.start); - if (tree.errors.len > 0) - return; - switch (node_tags[node]) { .block, .block_semicolon, .block_two, .block_two_semicolon => { const statements: []const ast.Node.Index = switch (node_tags[node]) { diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index 7e1fc99..72cecd0 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -1145,9 +1145,6 @@ fn writeNodeTokens( // TODO Range version, edit version. pub fn writeAllSemanticTokens(arena: *std.heap.ArenaAllocator, store: *DocumentStore, handle: *DocumentStore.Handle, encoding: offsets.Encoding) ![]u32 { var builder = Builder.init(arena.child_allocator, handle, encoding); - if (handle.tree.errors.len > 0) { - return builder.toOwnedSlice(); - } // reverse the ast from the root declarations var gap_highlighter = GapHighlighter.init(&builder, 0);