-
Notifications
You must be signed in to change notification settings - Fork 755
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
[Bug]: The code completion for annotation field is not working for some fields #40668
Comments
When investigated, I figured out that the ExpectedTypeAPI returns an invalid expected type at the cursor position depicted above. The syntax tree node at the cursor is a SpecificFieldNode. The expected type API uses the NodeFinder class to find the BLangNode node in a given range. In the above case the range given (specic field node in the annotation attachment) is not within the range of any of the topLevel nodes. Therefore, the node finder return null when the lookup() method in the NodeFinder is called. ballerina-lang/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java Line 227 in 0abb334
|
In the above example, we are trying to look up an annotAttachment by giving a pos inside it. First, we iterate over top-level nodes and the position of top-level nodes does not cover its' annotAttachment. That's why we are getting null here. We can,
For 2nd one, we need support from the parser and it is a change in the compiler front-end side. The 1st one can be done within NodeFinder.java and we have to check the other place that can have annotAttachements. @hasithaa, @gimantha, @MaryamZi, @pcnfernando WDYT? |
We can't do the 2, it is a backward incompatible change. +1 for 1st one. |
Blocked by #41186 |
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now. |
Description
When we have a union-typed field for an annotation (union of
int
andrecord
) and when we try to give it as a record value, the code completions are not working properly.Steps to Reproduce
Check the following code in vscode:
Affected Version(s)
Ballerina SwanLake 2201.6.0
OS, DB, other environment details and versions
Mac OS with Apple M1 chip
Related area
-> Editor
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: