Skip to content

Commit

Permalink
fix position context on identifier after parens
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Nov 27, 2023
1 parent 3c0728c commit c2bf5ec
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ pub fn getPositionContext(
curr_ctx.ctx = .{ .string_literal = tok.loc };
},
.identifier => switch (curr_ctx.ctx) {
.empty, .pre_label => curr_ctx.ctx = .{ .var_access = tok.loc },
.empty, .pre_label, .var_access => curr_ctx.ctx = .{ .var_access = tok.loc },
.label => |filled| if (!filled) {
curr_ctx.ctx = .{ .label = true };
} else {
Expand Down
86 changes: 42 additions & 44 deletions tests/utility/position_context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,30 @@ test "position context - var access" {
"Str",
);

// TODO fix failing tests
// try testContext(
// \\ fn foo() <cursor>Err!void {
// ,
// .var_access,
// "E",
// );
// try testContext(
// \\ fn foo() Er<cursor>r!void {
// ,
// .var_access,
// "Err",
// );
// try testContext(
// \\ fn foo() Err<cursor>!void {
// ,
// .var_access,
// "Err",
// );
// try testContext(
// \\ fn foo() Err!<cursor>void {
// ,
// .var_access,
// "v",
// );
try testContext(
\\ fn foo() <cursor>Err!void {
,
.var_access,
"E",
);
try testContext(
\\ fn foo() Er<cursor>r!void {
,
.var_access,
"Err",
);
try testContext(
\\ fn foo() Err<cursor>!void {
,
.var_access,
"Err",
);
try testContext(
\\ fn foo() Err!<cursor>void {
,
.var_access,
"v",
);

try testContext(
\\if (<cursor>bar.field == foo) {
Expand Down Expand Up @@ -239,25 +238,24 @@ test "position context - field access" {
"Foo.bar",
);

// TODO fix failing tests
// try testContext(
// \\fn foo() Foo.<cursor>bar!void {
// ,
// .field_access,
// "Foo.b",
// );
// try testContext(
// \\fn foo() Foo.ba<cursor>r!void {
// ,
// .field_access,
// "Foo.bar",
// );
// try testContext(
// \\fn foo() Foo.bar<cursor>!void {
// ,
// .field_access,
// "Foo.bar",
// );
try testContext(
\\fn foo() Foo.<cursor>bar!void {
,
.field_access,
"Foo.b",
);
try testContext(
\\fn foo() Foo.ba<cursor>r!void {
,
.field_access,
"Foo.bar",
);
try testContext(
\\fn foo() Foo.bar<cursor>!void {
,
.field_access,
"Foo.bar",
);
}

test "position context - builtin" {
Expand Down

0 comments on commit c2bf5ec

Please sign in to comment.