emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
642 stars 89 forks source link

Triggering code action while over operators in higher-order functions sometimes causes internal error #297

Open jacksonludwig opened 3 years ago

jacksonludwig commented 3 years ago

Describe the bug When triggering lsp-execute-code-action on code while the cursor is on an operator, e.g. -> or ., there is an internal error from the language server. I think this only happens in functional stuff like map. This doesn't always happen and unfortunately I have yet to find exactly what triggers it.

To Reproduce For example, take the following code and try to trigger a code action while the cursor over the lambda operator.

public static List<File> getListOfFiles() throws IOException {
        List<File> files;
        try (Stream<Path> path = Files.walk(FOLDER_OF_TEXT_FILES)) {
            files = path.filter(f -> Files.isRegularFile(f))
                        .map(f -> f.toFile())
                        .collect(Collectors.toList());
        }
        return files;
    }

Expected behavior Code action should trigger normally.

Screenshots image image

yyoncho commented 3 years ago

There should a callstack somewhere (most likely in lsp-log) or you will be able to see it by setting lsp-print-io to t and using lsp-workspace-show-log. I think in the end it is a server bug, I am seeing it too from time to time.