-
-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
completions: add result type based completions for builtin arguments #1720
completions: add result type based completions for builtin arguments #1720
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1720 +/- ##
==========================================
+ Coverage 78.49% 78.73% +0.24%
==========================================
Files 34 34
Lines 10648 10731 +83
==========================================
+ Hits 8358 8449 +91
+ Misses 2290 2282 -8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great but some new code completion tests would be nice.
df01f13
to
9a127f1
Compare
Oh yeah, sorry, forgot about this PR - I realised that nested completions don't currently work here, i.e. |
EDIT: Did a
Sure, diff --git a/src/features/completions.zig b/src/features/completions.zig
index 572e282..6983563 100644
--- a/src/features/completions.zig
+++ b/src/features/completions.zig
@@ -1193,6 +1193,11 @@ fn collectContainerNodes(
.field_access => |loc| try collectFieldAccessContainerNodes(analyser, arena, handle, loc, dot_context, &types_with_handles),
.enum_literal => |loc| try collectEnumLiteralContainerNodes(analyser, arena, handle, loc, &types_with_handles),
.builtin => |loc| try collectBuiltinContainerNodes(analyser, arena, handle, loc, dot_context, &types_with_handles),
+ .empty => blk: {
+ const name = handle.tree.tokenSlice(dot_context.identifier_token_index);
+ if (name.len < 1 and name[0] != '@' or name[1] == '"') break :blk;
+ try collectBuiltinContainerNodes(analyser, arena, handle, offsets.tokenToLoc(handle.tree, dot_context.identifier_token_index), dot_context, &types_with_handles);
+ },
else => {},
}
return types_with_handles.toOwnedSlice(arena); but my work is known to be at a low acceptance % :D |
15feeaa
to
dda3263
Compare
f1de644
to
c9867e8
Compare
c9867e8
to
7fcfdc5
Compare
7fcfdc5
to
6e98ced
Compare
6e98ced
to
4ebeccf
Compare
When writing arguments to builtins like `@Type`, even when using inferred initialization syntax (i.e. `@Type(.{ .`), completions are now provided. This case is detected in exactly the same way as the corresponding case for a normal function argument. This logic has been implemented for the following builtins, since they use a non-trivial type from `std.builtin`: * `@Type` * `@typeInfo` * `@src` * `@setFloatMode` * `@prefetch` * `@reduce` * `@export` * `@extern` * `@fence` * `@cmpxchg*` * `@atomic*` Co-authored-by: nullptrdevs <16590917+nullptrdevs@users.noreply.github.com> Co-authored-by: Techatrix <techatrix@mailbox.org>
4ebeccf
to
ba85a1b
Compare
After 5 months of negligence by me, it is finally time to get this merged. Soon™ |
When writing arguments to builtins like
@Type
, even when using inferred initialization syntax (i.e.@Type(.{ .
), completions are now provided. This case is detected in exactly the same way as the corresponding case for a normal function argument.This logic has been implemented for the following builtins, since they use a non-trivial type from
std.builtin
:@Type
@typeInfo
@src
@setFloatMode
@prefetch
@reduce
@export
@extern
@fence
@cmpxchg*
@atomic*