langium icon indicating copy to clipboard operation
langium copied to clipboard

Code Action: Adds Missing 'return' to Parser Rule

Open montymxb opened this issue 2 years ago • 1 comments

Closes one of the points of #442.

Adds return T to rule for general error

The type 'T' is already explicitly declared and cannot be inferred.

From https://github.com/langium/langium/issues/449.

Sep-23-2022 15-09-18

montymxb avatar Sep 23 '22 13:09 montymxb

There are a few cases that get mixed up in here which need a little more work to be separated cleanly. Missing returns & invalid returns are coupled together a bit, and invalid returns is in-turn coupled along with code that handles invalid infers. Plan is to come back to this at the start of Oct at the top of my list 📚 , and to clean this up a bit.

montymxb avatar Sep 23 '22 15:09 montymxb

Not exactly on time, completely past October actually 😆 . But did come back to work on this again, as it wasn't too much to change. Seems good now, and ready to check again.

montymxb avatar Nov 11 '22 13:11 montymxb

Alright, reworked this and it's now down to:

  • code action to add missing 'returns'
  • code action to correct invalid 'infers' (added due to some proximity)
  • same tests as before

Shaves down some of the changes for InvalidInfers by passing along the range of the appropriate CST node.

Missing returns case p1

Invalid infers case p2

The highlighting for invalid infers is only on the return type currently, let me know if that's a blocker.

montymxb avatar Nov 30 '22 16:11 montymxb

@montymxb Looks really nice! Is the same for Actions already planned.

dhuebner avatar Dec 07 '22 15:12 dhuebner

@dhuebner thanks! The original plan was to take care of the cases for parser rules, but it would be ideal to set that up for actions too. I believe once we have the code actions we want for parser rules, the same approach can be adapted to actions as well.

montymxb avatar Dec 08 '22 08:12 montymxb