mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
JSONRPC: Require manual method registration
This commit is contained in:
@@ -334,13 +334,50 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
|
||||
return bool(_EDITOR_GET("network/language_server/show_native_symbols_in_editor"));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
#define SET_DOCUMENT_METHOD(m_method) set_method(_STR(textDocument/m_method), callable_mp(text_document.ptr(), &GDScriptTextDocument::m_method))
|
||||
#define SET_COMPLETION_METHOD(m_method) set_method(_STR(completionItem/m_method), callable_mp(text_document.ptr(), &GDScriptTextDocument::m_method))
|
||||
#define SET_WORKSPACE_METHOD(m_method) set_method(_STR(workspace/m_method), callable_mp(workspace.ptr(), &GDScriptWorkspace::m_method))
|
||||
// clang-format on
|
||||
|
||||
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
|
||||
server.instantiate();
|
||||
singleton = this;
|
||||
workspace.instantiate();
|
||||
text_document.instantiate();
|
||||
set_scope("textDocument", text_document.ptr());
|
||||
set_scope("completionItem", text_document.ptr());
|
||||
set_scope("workspace", workspace.ptr());
|
||||
|
||||
SET_DOCUMENT_METHOD(didOpen);
|
||||
SET_DOCUMENT_METHOD(didClose);
|
||||
SET_DOCUMENT_METHOD(didChange);
|
||||
SET_DOCUMENT_METHOD(willSaveWaitUntil);
|
||||
SET_DOCUMENT_METHOD(didSave);
|
||||
|
||||
SET_DOCUMENT_METHOD(documentSymbol);
|
||||
SET_DOCUMENT_METHOD(completion);
|
||||
SET_DOCUMENT_METHOD(rename);
|
||||
SET_DOCUMENT_METHOD(prepareRename);
|
||||
SET_DOCUMENT_METHOD(references);
|
||||
SET_DOCUMENT_METHOD(foldingRange);
|
||||
SET_DOCUMENT_METHOD(codeLens);
|
||||
SET_DOCUMENT_METHOD(documentLink);
|
||||
SET_DOCUMENT_METHOD(colorPresentation);
|
||||
SET_DOCUMENT_METHOD(hover);
|
||||
SET_DOCUMENT_METHOD(definition);
|
||||
SET_DOCUMENT_METHOD(declaration);
|
||||
SET_DOCUMENT_METHOD(signatureHelp);
|
||||
|
||||
SET_DOCUMENT_METHOD(nativeSymbol); // Custom method.
|
||||
|
||||
SET_COMPLETION_METHOD(resolve);
|
||||
|
||||
SET_WORKSPACE_METHOD(didDeleteFiles);
|
||||
|
||||
set_method("initialize", callable_mp(this, &GDScriptLanguageProtocol::initialize));
|
||||
set_method("initialized", callable_mp(this, &GDScriptLanguageProtocol::initialized));
|
||||
|
||||
workspace->root = ProjectSettings::get_singleton()->get_resource_path();
|
||||
}
|
||||
|
||||
#undef SET_DOCUMENT_METHOD
|
||||
#undef SET_COMPLETION_METHOD
|
||||
#undef SET_WORKSPACE_METHOD
|
||||
|
||||
@@ -44,6 +44,14 @@ protected:
|
||||
|
||||
Ref<FileAccess> file_checker;
|
||||
|
||||
Array native_member_completions;
|
||||
|
||||
private:
|
||||
Array find_symbols(const LSP::TextDocumentPositionParams &p_location, List<const LSP::DocumentSymbol *> &r_list);
|
||||
LSP::TextDocumentItem load_document_item(const Variant &p_param);
|
||||
void notify_client_show_symbol(const LSP::DocumentSymbol *symbol);
|
||||
|
||||
public:
|
||||
void didOpen(const Variant &p_param);
|
||||
void didClose(const Variant &p_param);
|
||||
void didChange(const Variant &p_param);
|
||||
@@ -54,14 +62,6 @@ protected:
|
||||
void sync_script_content(const String &p_path, const String &p_content);
|
||||
void show_native_symbol_in_editor(const String &p_symbol_id);
|
||||
|
||||
Array native_member_completions;
|
||||
|
||||
private:
|
||||
Array find_symbols(const LSP::TextDocumentPositionParams &p_location, List<const LSP::DocumentSymbol *> &r_list);
|
||||
LSP::TextDocumentItem load_document_item(const Variant &p_param);
|
||||
void notify_client_show_symbol(const LSP::DocumentSymbol *symbol);
|
||||
|
||||
public:
|
||||
Variant nativeSymbol(const Dictionary &p_params);
|
||||
Array documentSymbol(const Dictionary &p_params);
|
||||
Array completion(const Dictionary &p_params);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
void GDScriptWorkspace::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("apply_new_signal"), &GDScriptWorkspace::apply_new_signal);
|
||||
ClassDB::bind_method(D_METHOD("didDeleteFiles"), &GDScriptWorkspace::did_delete_files);
|
||||
ClassDB::bind_method(D_METHOD("didDeleteFiles"), &GDScriptWorkspace::didDeleteFiles);
|
||||
ClassDB::bind_method(D_METHOD("parse_script", "path", "content"), &GDScriptWorkspace::parse_script);
|
||||
ClassDB::bind_method(D_METHOD("parse_local_script", "path"), &GDScriptWorkspace::parse_local_script);
|
||||
ClassDB::bind_method(D_METHOD("get_file_path", "uri"), &GDScriptWorkspace::get_file_path);
|
||||
@@ -106,7 +106,7 @@ void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStr
|
||||
GDScriptLanguageProtocol::get_singleton()->request_client("workspace/applyEdit", params.to_json());
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::did_delete_files(const Dictionary &p_params) {
|
||||
void GDScriptWorkspace::didDeleteFiles(const Dictionary &p_params) {
|
||||
Array files = p_params["files"];
|
||||
for (int i = 0; i < files.size(); ++i) {
|
||||
Dictionary file = files[i];
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
void resolve_document_links(const String &p_uri, List<LSP::DocumentLink> &r_list);
|
||||
Dictionary generate_script_api(const String &p_path);
|
||||
Error resolve_signature(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::SignatureHelp &r_signature);
|
||||
void did_delete_files(const Dictionary &p_params);
|
||||
void didDeleteFiles(const Dictionary &p_params);
|
||||
Dictionary rename(const LSP::TextDocumentPositionParams &p_doc_pos, const String &new_name);
|
||||
bool can_rename(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::DocumentSymbol &r_symbol, LSP::Range &r_range);
|
||||
Vector<LSP::Location> find_usages_in_file(const LSP::DocumentSymbol &p_symbol, const String &p_file_path);
|
||||
|
||||
Reference in New Issue
Block a user