Skip to content
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

feat(c_sharp) add @assignment support for all possible assignable statements #720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

prashanthsp6498
Copy link

Supports for all assignment statements.

Lambda Method

    public static string Method() => $"return result";

class/struct/record fields

    const int CONST_FIELD = 10;
    public static Node head;
    public static Node tempHead = new Node();

local variables declarations

    int count = 10;
    int[] arr = new int[] {1, 2, 3, 4, 5, 6};
    head = new Node{data = arr[0]};
    count = 100;

Above local fields also support in field scope

…ements

Supports for all assignment statements.

Lambda Method
```cs
    public static string Method() => $"return result";
```

class/struct/record fields
```cs
    const int CONST_FIELD = 10;
    public static Node head;
    public static Node tempHead = new Node();

```

local variables declarations
```cs
    int count = 10;
    int[] arr = new int[] {1, 2, 3, 4, 5, 6};
    head = new Node{data = arr[0]};
    count = 100;
```
Above local fields also support in field scope
@prashanthsp6498
Copy link
Author

Any update on this PR...

@kiyoon
Copy link
Collaborator

kiyoon commented Dec 4, 2024

@prashanthsp6498 Hi, sorry for the delay. C# is not a language I personally use and I find it time-consuming to test all query PRs.
Could you kindly add some test cases?

  1. Make an example C# file in tests/select/c_sharp/* (the same as the description is fine)
  2. The assignment textobjects are not defined in the scripts/minimal_init.lua. Add bindings for ig (@assignment.inner), ag (@assignment.outer), ik (@assignment.lhs), iv (@assignment.rhs). The k and v refers to key and value.
  3. Write tests/select/c_sharp_spec.lua similar to the one in python. Make sure you write clear comments to indicate what the test is doing.
    a. For example, I would equality-compare commands like vt=bd (delete everything before = sign, except for the spaces) with dig and dik. All three commands should produce equal results. Make the default vim command robust and easy to understand (e.g. avoid v10ld because it's easy to be broken when the reference file changes a bit.)

@clason I think this should be mandatory in all query PRs. It's hard to really keep track of all queries manually.

(expression_statement
(assignment_expression
left: (_) @assignment.lhs
right: (_) @assignment.rhs)) @assignment.inner @assignment.outer
Copy link
Collaborator

@kiyoon kiyoon Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inner and outer should not mean the same thing. Inner refers to "either" LHS or RHS, outer means select both. Sorry, this isn't documented very clearly as of now. (although I wrote a comment on this query, all queries seem to be wrong and need to be fixed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will fix these queries and add test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants