feat: implement `Convert to collect` code action
sorry for late response, i accidentally marked notification to this as None.
i'm fine with either approach; (to be honest, doesn't know which way is the best)
if you are interested I can explain exactly what can be done and let you work on that
that would be great!
I will try to merge https://github.com/scalameta/metals/pull/6978 tomorrow, but it adds the possibility of using codeAction/resolve.
We can add something similar to FilterMapChain class to data and no edits. If not edits are provided codeAction/resolve will be invoked, where we can additionally check if collect exists by:
- First send go to compilers.definition on filter or map
- Replace last
maporfilterwithcollectin the semanticdb symbol - Use compilers.info to see if that symbol exists and if it exists if it's in an expected shape.
- If that's known we just create the edits.
Ok, the other PR is merged, let me know if you have any problems with what I suggested, I can also help finish the PR
currently stuck on NPE while converting to codeAction/resolve.
==> X tests.codeactions.FilterMapToCollectCodeActionSuite.cursor-on-filter 4.928s java.lang.NullPointerException: Cannot invoke "org.eclipse.lsp4j.Range.getStart()" because "range$1" is null
let me know if you have any problems with what I suggested, I can also help finish the PR
I'd be grateful!
@tgodzik i've rebased and migrated to codeAction/resolve. still stuck on semanticDB part.
strangely, while it doesn't happen on my local machine the NPE still seems to happen in CI:
tests.codeactions.FilterMapToCollectCodeActionSuite:
+ cursor-on-filter 8.24s
+ cursor-on-filter-newline 2.663s
+ cursor-on-map 2.07s
+ higher-order-function 1.943s
+ higher-order-function-rename-filter-argument 1.924s
+ higher-order-function-rename-map-argument 1.516s
+ multiple-map-calls 1.744s
+ complex-predicate 1.779s
+ multiline-predicate 1.406s
+ multiline-predicate-block 1.843s
+ with-type-annotations 1.632s
[info] Passed: Total 11, Failed 0, Errors 0, Passed 11
https://github.com/scalameta/metals/actions/runs/12094357358/job/33726319967?pr=6969#step:5:1816