summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/language_server/gdscript_language_protocol.cpp
diff options
context:
space:
mode:
authorGeequlim <geequlim@gmail.com>2019-06-26 20:21:42 +0800
committergeequlim <geequlim@gmail.com>2019-08-11 13:30:15 +0800
commit666ed89011551ae7691c8eeeb3fff74e17b48020 (patch)
treede25d18a89465cf45856cf8484e0f4ed669e632c /modules/gdscript/language_server/gdscript_language_protocol.cpp
parent9618b0c63e3330865350bd8bbc6a9d2faf9dd26c (diff)
downloadredot-engine-666ed89011551ae7691c8eeeb3fff74e17b48020.tar.gz
Add generate script api to dictionary support
Expose GDScriptLanguageProtocol singleton and classes for editor plugins (Not visiable in class tree) Fix minor bug in symbol resolve
Diffstat (limited to 'modules/gdscript/language_server/gdscript_language_protocol.cpp')
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 9ebabc276e..98b5c28130 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -86,6 +86,12 @@ void GDScriptLanguageProtocol::_bind_methods() {
ClassDB::bind_method(D_METHOD("on_data_received"), &GDScriptLanguageProtocol::on_data_received);
ClassDB::bind_method(D_METHOD("on_client_connected"), &GDScriptLanguageProtocol::on_client_connected);
ClassDB::bind_method(D_METHOD("on_client_disconnected"), &GDScriptLanguageProtocol::on_client_disconnected);
+ ClassDB::bind_method(D_METHOD("notify_all_clients", "p_method", "p_params"), &GDScriptLanguageProtocol::notify_all_clients, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("notify_client", "p_method", "p_params", "p_client"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("is_smart_resolve_enabled"), &GDScriptLanguageProtocol::is_smart_resolve_enabled);
+ ClassDB::bind_method(D_METHOD("get_text_document"), &GDScriptLanguageProtocol::get_text_document);
+ ClassDB::bind_method(D_METHOD("get_workspace"), &GDScriptLanguageProtocol::get_workspace);
+ ClassDB::bind_method(D_METHOD("is_initialized"), &GDScriptLanguageProtocol::is_initialized);
}
Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
@@ -94,20 +100,20 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
String root_uri = p_params["rootUri"];
String root = p_params["rootPath"];
- bool is_same_workspace = root == workspace.root;
- is_same_workspace = root.to_lower() == workspace.root.to_lower();
+ bool is_same_workspace = root == workspace->root;
+ is_same_workspace = root.to_lower() == workspace->root.to_lower();
#ifdef WINDOWS_ENABLED
- is_same_workspace = root.replace("\\", "/").to_lower() == workspace.root.to_lower();
+ is_same_workspace = root.replace("\\", "/").to_lower() == workspace->root.to_lower();
#endif
if (root_uri.length() && is_same_workspace) {
- workspace.root_uri = root_uri;
+ workspace->root_uri = root_uri;
} else {
- workspace.root_uri = "file://" + workspace.root;
+ workspace->root_uri = "file://" + workspace->root;
Dictionary params;
- params["path"] = workspace.root;
+ params["path"] = workspace->root;
Dictionary request = make_notification("gdscrip_client/changeWorkspace", params);
if (Ref<WebSocketPeer> *peer = clients.getptr(lastest_client_id)) {
String msg = JSON::print(request);
@@ -118,8 +124,8 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
}
if (!_initialized) {
- workspace.initialize();
- text_document.initialize();
+ workspace->initialize();
+ text_document->initialize();
_initialized = true;
}
@@ -187,10 +193,12 @@ GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
server = NULL;
singleton = this;
_initialized = false;
- set_scope("textDocument", &text_document);
- set_scope("completionItem", &text_document);
- set_scope("workspace", &workspace);
- workspace.root = ProjectSettings::get_singleton()->get_resource_path();
+ workspace.instance();
+ text_document.instance();
+ set_scope("textDocument", text_document.ptr());
+ set_scope("completionItem", text_document.ptr());
+ set_scope("workspace", workspace.ptr());
+ workspace->root = ProjectSettings::get_singleton()->get_resource_path();
}
GDScriptLanguageProtocol::~GDScriptLanguageProtocol() {