Implement abstract function - Extend to support external methods (Java standard library etc.) #357
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
General information
The current implementation only supports extending classes or implementing interfaces in the same project it seems. I often work with Java libraries where I have to implement functions from abstract classes or interfaces. This can be very tedious to do manually, so having it as a quickfix is really beneficial. The current implementation is based on KtClass, which to my understanding is only made for Kotlin classes. Java classes have their own PSI elements in the compiler. In the current implementation, we are also shown that a quickfix exists, but the edit-parts of it are empty/null.
The new implementation works with the DeclarationDescriptor objects directly, which seems like a very flexible approach.
Quirks
I originally did not see the QuickFixesTests file, so I originally had a different file with tests. That is why it seems like there is some overlap between some of the tests. I later merged them, but decided to keep the tests. I think the set of tests verifies a lot of different things; same file definitions, workspace definitions in other files, and Java standard library ones. Let me know if I instead should delete some of them.
I blame late evening coding after a beer for not noticing the QuickFixesTests file 😆
Future work
There are some useful things that should be added to this functionality. To not make this PR too big, I think it is better to have them as part of a future PR. Will Make some issues for them so people can pick them up if they want to (or I end up doing it when I have time after work).