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 04434d9
Show file tree
Hide file tree
Showing 5 changed files with 2,135 additions and 148 deletions.
11 changes: 10 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 @@ -1327,6 +1327,15 @@ pub fn uriFromImportStr(self: *DocumentStore, allocator: std.mem.Allocator, hand
}
return null;
} else if (!std.mem.endsWith(u8, import_str, ".zig")) {
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);
}
}
}
if (handle.associated_build_file) |build_file_uri| blk: {
const build_file = self.getBuildFile(build_file_uri).?;
const config = build_file.config orelse break :blk;
Expand Down
Loading

0 comments on commit 04434d9

Please sign in to comment.