From b2f02317fabe284220c74c21229e4cad6ab74e93 Mon Sep 17 00:00:00 2001 From: Geequlim Date: Tue, 25 Jun 2019 12:12:41 +0800 Subject: Improve symbol resolve for inner classes Only level one inner classes would be resolved currently but it sould cover most real world use case Improve documation parseing for const values Improve documation format for native symbols --- .../language_server/gdscript_workspace.cpp | 53 ++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'modules/gdscript/language_server/gdscript_workspace.cpp') diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 089c19e6a4..ec95ea5765 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -170,14 +170,6 @@ String GDScriptWorkspace::marked_documentation(const String &p_bbcode) { markdown = ""; for (int i = 0; i < lines.size(); i++) { String line = lines[i]; - line = line.replace("[code]", "`"); - line = line.replace("[/code]", "`"); - line = line.replace("[i]", "*"); - line = line.replace("[/i]", "*"); - line = line.replace("[b]", "**"); - line = line.replace("[/b]", "**"); - line = line.replace("[u]", "__"); - line = line.replace("[/u]", "__"); int block_start = line.find("[codeblock]"); if (block_start != -1) { code_block_indent = block_start; @@ -186,14 +178,31 @@ String GDScriptWorkspace::marked_documentation(const String &p_bbcode) { line = "\n"; } else if (in_code_block) { line = "\t" + line.substr(code_block_indent, line.length()); - } else { - line = line.strip_edges(); } + if (in_code_block && line.find("[/codeblock]") != -1) { line = "'''\n"; line = "\n"; in_code_block = false; } + + if (!in_code_block) { + line = line.strip_edges(); + line = line.replace("[code]", "`"); + line = line.replace("[/code]", "`"); + line = line.replace("[i]", "*"); + line = line.replace("[/i]", "*"); + line = line.replace("[b]", "**"); + line = line.replace("[/b]", "**"); + line = line.replace("[u]", "__"); + line = line.replace("[/u]", "__"); + line = line.replace("[method ", "`"); + line = line.replace("[member ", "`"); + line = line.replace("[signal ", "`"); + line = line.replace("[", "`"); + line = line.replace("]", "`"); + } + if (!in_code_block && i < lines.size() - 1) { line += "\n"; } @@ -310,6 +319,8 @@ Error GDScriptWorkspace::initialize() { native_symbols.insert(class_name, class_symbol); } + reload_all_workspace_scripts(); + if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { for (Map::Element *E = native_symbols.front(); E; E = E->next()) { ClassMembers members; @@ -320,9 +331,12 @@ Error GDScriptWorkspace::initialize() { } native_members.set(E->key(), members); } - } - reload_all_workspace_scripts(); + // cache member completions + for (Map::Element *S = scripts.front(); S; S = S->next()) { + S->get()->get_member_completions(); + } + } return OK; } @@ -477,10 +491,23 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP } for (Map::Element *E = scripts.front(); E; E = E->next()) { - const ClassMembers &members = E->get()->get_members(); + const ExtendGDScriptParser *script = E->get(); + const ClassMembers &members = script->get_members(); if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) { r_list.push_back(*symbol); } + + const HashMap &inner_classes = script->get_inner_classes(); + const String *_class = inner_classes.next(NULL); + while (_class) { + + const ClassMembers *inner_class = inner_classes.getptr(*_class); + if (const lsp::DocumentSymbol *const *symbol = inner_class->getptr(symbol_identifier)) { + r_list.push_back(*symbol); + } + + _class = inner_classes.next(_class); + } } } } -- cgit v1.2.3