From 666ed89011551ae7691c8eeeb3fff74e17b48020 Mon Sep 17 00:00:00 2001 From: Geequlim Date: Wed, 26 Jun 2019 20:21:42 +0800 Subject: 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 --- .../language_server/gdscript_text_document.cpp | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'modules/gdscript/language_server/gdscript_text_document.cpp') diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index cb42e31644..424cad5a42 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -77,7 +77,7 @@ void GDScriptTextDocument::initialize() { if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { - const HashMap &native_members = GDScriptLanguageProtocol::get_singleton()->get_workspace().native_members; + const HashMap &native_members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members; const StringName *class_ptr = native_members.next(NULL); while (class_ptr) { @@ -103,9 +103,9 @@ void GDScriptTextDocument::initialize() { Array GDScriptTextDocument::documentSymbol(const Dictionary &p_params) { Dictionary params = p_params["textDocument"]; String uri = params["uri"]; - String path = GDScriptLanguageProtocol::get_singleton()->get_workspace().get_file_path(uri); + String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(uri); Array arr; - if (const Map::Element *parser = GDScriptLanguageProtocol::get_singleton()->get_workspace().scripts.find(path)) { + if (const Map::Element *parser = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.find(path)) { Vector list; parser->get()->get_symbols().symbol_tree_as_list(uri, list); for (int i = 0; i < list.size(); i++) { @@ -124,7 +124,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { Dictionary request_data = params.to_json(); List options; - GDScriptLanguageProtocol::get_singleton()->get_workspace().completion(params, &options); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->completion(params, &options); if (!options.empty()) { @@ -178,7 +178,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { arr = native_member_completions.duplicate(); - for (Map::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace().scripts.front(); E; E = E->next()) { + for (Map::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.front(); E; E = E->next()) { ExtendGDScriptParser *script = E->get(); const Array &items = script->get_member_completions(); @@ -206,7 +206,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { if (data.get_type() == Variant::DICTIONARY) { params.load(p_params["data"]); - symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace().resolve_symbol(params, item.label, item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function); + symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params, item.label, item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function); } else if (data.get_type() == Variant::STRING) { @@ -224,14 +224,14 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { inner_class_name = param_symbols[1]; } - if (const ClassMembers *members = GDScriptLanguageProtocol::get_singleton()->get_workspace().native_members.getptr(class_name)) { + if (const ClassMembers *members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members.getptr(class_name)) { if (const lsp::DocumentSymbol *const *member = members->getptr(member_name)) { symbol = *member; } } if (!symbol) { - if (const Map::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace().scripts.find(class_name)) { + if (const Map::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.find(class_name)) { symbol = E->get()->get_member_symbol(member_name, inner_class_name); } } @@ -284,7 +284,7 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) { lsp::TextDocumentPositionParams params; params.load(p_params); - const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace().resolve_symbol(params); + const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params); if (symbol) { lsp::Hover hover; @@ -296,7 +296,7 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) { Dictionary ret; Array contents; List list; - GDScriptLanguageProtocol::get_singleton()->get_workspace().resolve_related_symbols(params, list); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list); for (List::Element *E = list.front(); E; E = E->next()) { if (const lsp::DocumentSymbol *s = E->get()) { contents.push_back(s->render().value); @@ -315,20 +315,20 @@ Array GDScriptTextDocument::definition(const Dictionary &p_params) { lsp::TextDocumentPositionParams params; params.load(p_params); - const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace().resolve_symbol(params); + const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params); if (symbol) { lsp::Location location; location.uri = symbol->uri; location.range = symbol->range; - const String &path = GDScriptLanguageProtocol::get_singleton()->get_workspace().get_file_path(symbol->uri); + const String &path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(symbol->uri); if (file_checker->file_exists(path)) { arr.push_back(location.to_json()); } } else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { List list; - GDScriptLanguageProtocol::get_singleton()->get_workspace().resolve_related_symbols(params, list); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list); for (List::Element *E = list.front(); E; E = E->next()) { if (const lsp::DocumentSymbol *s = E->get()) { @@ -354,6 +354,6 @@ GDScriptTextDocument::~GDScriptTextDocument() { } void GDScriptTextDocument::sync_script_content(const String &p_uri, const String &p_content) { - String path = GDScriptLanguageProtocol::get_singleton()->get_workspace().get_file_path(p_uri); - GDScriptLanguageProtocol::get_singleton()->get_workspace().parse_script(path, p_content); + String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(p_uri); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content); } -- cgit v1.2.3