ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

Fix providing invalid fix return type code action for anonymous functions

Open LakshanWeerasinghe opened this issue 1 year ago • 2 comments
trafficstars

Purpose

$subject

Fixes #42820

Approach

Previously, when identifying a potential scenario for a "fix return type" code action, we located the enclosing function node. However, if the actual error scenario was within an anonymous function, we attempted to update the enclosing function of that anonymous function, causing the error behaviour.

To address this, we now first correctly identify the enclosing node when an error is within an anonymous function. Once we have the correct enclosing node, we follow the same approach to generate the appropriate code action.

Samples

https://github.com/ballerina-platform/ballerina-lang/assets/46857198/9de8b7db-7668-473b-be6a-4494c29b7823

Remarks

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [x] Added necessary tests
    • [x] Unit Tests
    • [ ] Spec Conformance Tests
    • [ ] Integration Tests
    • [ ] Ballerina By Example Tests
  • [ ] Increased Test Coverage
  • [ ] Added necessary documentation
    • [x] API documentation
    • [ ] Module documentation in Module.md files
    • [ ] Ballerina By Examples

LakshanWeerasinghe avatar Jun 14 '24 05:06 LakshanWeerasinghe