restrain cross-file symbol references within it's build system module#2608
Merged
restrain cross-file symbol references within it's build system module#2608
Conversation
Preparation for better cross-file references.
A percent encoding with one upper and one lower case letter would not be normalized properly. Also avoids unnecessary loop iterations when encountering an already normalized percent encoding.
This enable imports to be resolved on documents with non `file` uri scheme.
This logic is mostly guesswork. Perhaps we can bring it back after fixing cross file references.
Please Andrew, remove cImport from the language. I beg you.
When requesting references on a file that is within a build system module, the search will be constrained within the given module. This does not account for references across modules (or projects) which may be implemented in the future. When the file is not part of a build system module, the search will be across all files that are loaded by ZLS. With workspace symbols (#2339) all files in workspace folders will be loaded. Files that never (transitively) import the target symbol file will be filtered out so this isn't necessarily as slow as it may sound like.
8a9cb60 to
7508e06
Compare
Contributor
// a.zig
const b = @import("b.zig");
const Foo = b.Foo;
comptime {
_ = Foo;
}
// b.zig
pub const Foo = struct {};this fails to find the |
Only works for aliases that do not rename the symbol. ```zig const A = foo.A; // works const B = foo.A; // doesn't work because the symbol was renamed ```
7508e06 to
d387dd5
Compare
Member
Author
Fixed. |
This was referenced Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1071
When requesting references on a file that is within a build system module, the search will be constrained within the given module. This should give more predictable results compared to flawed approach that is preceded it (see #1071). However, this does not yet account from references across modules (or projects) which can be implemented in the future.
This change also fixes an issue with #2339 where symbol references would load all build files inside of the workspace. This is especially problematic with projects that have many build files like the Zig compiler codebase.
Followup Issues: