summaryrefslogtreecommitdiff
path: root/modules/gdscript/language_server/gdscript_workspace.cpp
diff options
context:
space:
mode:
authorGeequlim <geequlim@gmail.com>2019-06-25 12:12:41 +0800
committergeequlim <geequlim@gmail.com>2019-08-11 13:30:15 +0800
commitb2f02317fabe284220c74c21229e4cad6ab74e93 (patch)
tree71817f93ffe84e92eed24accf2420bdfc41a2679 /modules/gdscript/language_server/gdscript_workspace.cpp
parent76c9e4ceb73b02bd95ab0512e27229516208dc60 (diff)
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
Diffstat (limited to 'modules/gdscript/language_server/gdscript_workspace.cpp')
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp53
1 files changed, 40 insertions, 13 deletions
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<StringName, lsp::DocumentSymbol>::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<String, ExtendGDScriptParser *>::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<String, ExtendGDScriptParser *>::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<String, ClassMembers> &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);
+ }
}
}
}