Skip to content

Commit

Permalink
Full build runners
Browse files Browse the repository at this point in the history
 - Resolve mod imports in `build.zig`s
 - Show completions for mod imports in `build.zig`s
  • Loading branch information
llogick committed Nov 1, 2023
1 parent 176bfab commit 1a3ab5a
Show file tree
Hide file tree
Showing 5 changed files with 2,134 additions and 148 deletions.
10 changes: 9 additions & 1 deletion src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ pub fn getBuildFile(self: *DocumentStore, uri: Uri) ?BuildFile {

/// invalidates any pointers into `DocumentStore.build_files`
/// **Thread safe** takes an exclusive lock
fn getOrLoadBuildFile(self: *DocumentStore, uri: Uri) ?std.StringArrayHashMapUnmanaged(BuildFile).Entry {
pub fn getOrLoadBuildFile(self: *DocumentStore, uri: Uri) ?std.StringArrayHashMapUnmanaged(BuildFile).Entry {
{
self.lock.lockShared();
defer self.lock.unlockShared();
Expand Down Expand Up @@ -1335,6 +1335,14 @@ pub fn uriFromImportStr(self: *DocumentStore, allocator: std.mem.Allocator, hand
return try URI.fromPath(allocator, pkg.path);
}
}
} else if (isBuildFile(handle.uri)) {
const build_file_entry = self.getOrLoadBuildFile(handle.uri) orelse return null;
const config = build_file_entry.value_ptr.config orelse return null;
for (config.value.deps_build_roots) |dep_build_root| {
if (std.mem.eql(u8, import_str, dep_build_root.name)) {
return try URI.fromPath(allocator, dep_build_root.path);
}
}
}
return null;
} else {
Expand Down
Loading

0 comments on commit 1a3ab5a

Please sign in to comment.