From c55363e2c2db2407da2139b250ba2bf8ff4700f3 Mon Sep 17 00:00:00 2001 From: Sergeeeek Date: Tue, 19 May 2020 12:02:48 +0300 Subject: [PATCH] Code style fixes --- src/document_store.zig | 13 +++++-------- src/main.zig | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/document_store.zig b/src/document_store.zig index 5404043..084968c 100644 --- a/src/document_store.zig +++ b/src/document_store.zig @@ -230,8 +230,7 @@ pub fn applyChanges(self: *DocumentStore, handle: *Handle, content_changes: std. fn uriFromImportStr(store: *DocumentStore, allocator: *std.mem.Allocator, handle: Handle, import_str: []const u8) !?[]const u8 { return if (std.mem.eql(u8, import_str, "std")) - if (store.std_uri) |std_root_uri| try std.mem.dupe(allocator, u8, std_root_uri) - else { + if (store.std_uri) |std_root_uri| try std.mem.dupe(allocator, u8, std_root_uri) else { std.debug.warn("Cannot resolve std library import, path is null.\n", .{}); return null; } @@ -241,8 +240,8 @@ fn uriFromImportStr(store: *DocumentStore, allocator: *std.mem.Allocator, handle defer allocator.free(path); const dir_path = std.fs.path.dirname(path) orelse ""; - const import_path = try std.fs.path.resolve(allocator, &[_][]const u8 { - dir_path, import_str + const import_path = try std.fs.path.resolve(allocator, &[_][]const u8{ + dir_path, import_str, }); defer allocator.free(import_path); @@ -252,8 +251,6 @@ fn uriFromImportStr(store: *DocumentStore, allocator: *std.mem.Allocator, handle } pub const AnalysisContext = struct { - const Self = @This(); - store: *DocumentStore, handle: *Handle, // This arena is used for temporary allocations while analyzing, @@ -342,10 +339,10 @@ pub const AnalysisContext = struct { return &self.tree.root_node.base; } - pub fn clone(self: *Self) !Self { + pub fn clone(self: *AnalysisContext) !AnalysisContext { // Create a new tree so it can be destroyed by the cloned AnalysisContext without affecting the original const tree = try self.handle.tree(self.store.allocator); - return Self{ + return AnalysisContext{ .store = self.store, .handle = self.handle, .arena = self.arena, diff --git a/src/main.zig b/src/main.zig index abaf31c..bace367 100644 --- a/src/main.zig +++ b/src/main.zig @@ -355,7 +355,10 @@ fn completeGlobal(id: i64, pos_index: usize, handle: *DocumentStore.Handle, conf // Deallocate all temporary data. defer arena.deinit(); - var analysis_ctx = try document_store.analysisContext(handle, &arena, types.Position{.line = 0, .character = 0,}); + var analysis_ctx = try document_store.analysisContext(handle, &arena, types.Position{ + .line = 0, + .character = 0, + }); defer analysis_ctx.deinit(); var decl_nodes = std.ArrayList(*std.zig.ast.Node).init(&arena.allocator);