Closed ginqi7 closed 5 days ago
我更新最新版的 lsp-bridge,在 Java 代码里运行 lsp-bridge-code-action,无法弹出任何的选项。
I update to the latest lsp-bridge, it cannot pop candidates when I run lsp-bridge-code-action in Java.
lsp-bridge-code-action
我发现 fileaction.py 文件里新增了 code_action_has_valid_edits 方法对 actions 进行校验。但 jdtls 返回的 actions 信息都无法通过该验证。
fileaction.py
code_action_has_valid_edits
I find code_action_has_valid_edits in fileaction.py. It will check if code action valid, But jdtls code action response couldn't pass it.
一个基本的测试代码:
My test java code:
public class Hello { public static void main(String[] args) { test(); } }
旧版本里,code-action 会弹出如下选项:
In old version, code-action will show:
lsp-bridge 返回的日志:
The response log is:
--- [21:17:39.090670] Record actions from 'jdtls' for file Hello.java {'jdtls': [{'title': "Create method 'test()'", 'kind': 'quickfix', 'diagnostics': [{'range': {'start': {'line': 2, 'character': 1}, 'end': {'line': 2, 'character': 5}}, 'severity': 1, 'code': '67108964', 'source': 'Java', 'message': 'The method test() is undefined for the type Hello'}], 'command': {'title': "Create method 'test()'", 'command': 'java.apply.workspaceEdit', 'arguments': [{'changes': {'file:///Users/a77/Downloads/JavaTest/Hello.java': [{'range': {'start': {'line': 2, 'character': 1}, 'end': {'line': 3, 'character': 5}}, 'newText': 'test();\n }\n\n\tprivate static void test() {\n\t\t// TODO Auto-generated method stub\n\t\tthrow new UnsupportedOperationException("Unimplemented method \'test\'");\n\t}'}]}}]}}, {'title': "Add Javadoc for 'main'", 'command': 'java.apply.workspaceEdit', 'arguments': [{'changes': {'file:///Users/a77/Downloads/JavaTest/Hello.java': [{'range': {'start': {'line': 1, 'character': 4}, 'end': {'line': 1, 'character': 4}}, 'newText': '/**\n * @param args\n */\n '}]}}]}, {'title': 'Generate toString()', 'kind': 'source.generate.toString', 'diagnostics': [{'range': {'start': {'line': 2, 'character': 1}, 'end': {'line': 2, 'character': 5}}, 'severity': 1, 'code': '67108964', 'source': 'Java', 'message': 'The method test() is undefined for the type Hello'}], 'command': {'title': 'Generate toString()', 'command': 'java.apply.workspaceEdit', 'arguments': [{'changes': {'file:///Users/a77/Downloads/JavaTest/Hello.java': [{'range': {'start': {'line': 3, 'character': 5}, 'end': {'line': 3, 'character': 5}}, 'newText': '\n\n\t@Override\n\tpublic String toString() {\n\t\treturn "Hello []";\n\t}'}]}}]}}, {'title': 'Override/Implement Methods...', 'kind': 'source.overrideMethods', 'diagnostics': [], 'command': {'title': 'Override/Implement Methods...', 'command': 'java.action.overrideMethodsPrompt', 'arguments': [{'textDocument': {'uri': 'file:///Users/a77/Downloads/JavaTest/Hello.java'}, 'range': {'start': {'line': 2, 'character': 1}, 'end': {'line': 2, 'character': 5}}, 'context': {'diagnostics': [{'range': {'start': {'line': 2, 'character': 1}, 'end': {'line': 2, 'character': 5}}, 'severity': 1, 'code': '67108964', 'source': 'Java', 'message': 'The method test() is undefined for the type Hello'}]}}]}}, {'title': 'Change modifiers to final where possible', 'kind': 'source.generate.finalModifiers', 'diagnostics': [], 'command': {'title': 'Change modifiers to final where possible', 'command': 'java.apply.workspaceEdit', 'arguments': [{'changes': {'file:///Users/a77/Downloads/JavaTest/Hello.java': [{'range': {'start': {'line': 1, 'character': 28}, 'end': {'line': 1, 'character': 28}}, 'newText': 'final '}]}}]}}]}
已经修复了, 感谢反馈
我更新最新版的 lsp-bridge,在 Java 代码里运行 lsp-bridge-code-action,无法弹出任何的选项。
I update to the latest lsp-bridge, it cannot pop candidates when I run
lsp-bridge-code-action
in Java.我发现
fileaction.py
文件里新增了code_action_has_valid_edits
方法对 actions 进行校验。但 jdtls 返回的 actions 信息都无法通过该验证。I find
code_action_has_valid_edits
infileaction.py
. It will check if code action valid, But jdtls code action response couldn't pass it.一个基本的测试代码:
My test java code:
旧版本里,code-action 会弹出如下选项:
In old version, code-action will show:
lsp-bridge 返回的日志:
The response log is: