mirror of
https://github.com/godotengine/godot
synced 2024-09-05 02:18:26 +00:00
Add optional goto definition support for native symbols
This action will show help for target symbol in godot editor and bring the godot editor window to foreground Improved markdown documentation for symbols.
This commit is contained in:
parent
666ed89011
commit
72d11cd173
|
@ -123,7 +123,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||||
r_symbol.selectionRange.start.line = r_symbol.range.start.line;
|
r_symbol.selectionRange.start.line = r_symbol.range.start.line;
|
||||||
r_symbol.detail = "class " + r_symbol.name;
|
r_symbol.detail = "class " + r_symbol.name;
|
||||||
bool is_root_class = &r_symbol == &class_symbol;
|
bool is_root_class = &r_symbol == &class_symbol;
|
||||||
r_symbol.documentation = parse_documentation(is_root_class ? 0 : LINE_NUMBER_TO_INDEX(p_class->line), is_root_class);
|
r_symbol.documentation = parse_documentation_as_markdown(is_root_class ? 0 : LINE_NUMBER_TO_INDEX(p_class->line), is_root_class);
|
||||||
|
|
||||||
for (int i = 0; i < p_class->variables.size(); ++i) {
|
for (int i = 0; i < p_class->variables.size(); ++i) {
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||||
symbol.detail += " = " + JSON::print(m.default_value);
|
symbol.detail += " = " + JSON::print(m.default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol.documentation = parse_documentation(line);
|
symbol.documentation = parse_documentation_as_markdown(line);
|
||||||
symbol.uri = uri;
|
symbol.uri = uri;
|
||||||
symbol.script_path = path;
|
symbol.script_path = path;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||||
symbol.range.end.line = symbol.range.start.line;
|
symbol.range.end.line = symbol.range.start.line;
|
||||||
symbol.range.end.character = lines[line].length();
|
symbol.range.end.character = lines[line].length();
|
||||||
symbol.selectionRange.start.line = symbol.range.start.line;
|
symbol.selectionRange.start.line = symbol.range.start.line;
|
||||||
symbol.documentation = parse_documentation(line);
|
symbol.documentation = parse_documentation_as_markdown(line);
|
||||||
symbol.uri = uri;
|
symbol.uri = uri;
|
||||||
symbol.script_path = path;
|
symbol.script_path = path;
|
||||||
symbol.detail = "signal " + signal.name + "(";
|
symbol.detail = "signal " + signal.name + "(";
|
||||||
|
@ -198,7 +198,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||||
symbol.range.end.line = symbol.range.start.line;
|
symbol.range.end.line = symbol.range.start.line;
|
||||||
symbol.range.end.character = lines[line].length();
|
symbol.range.end.character = lines[line].length();
|
||||||
symbol.selectionRange.start.line = symbol.range.start.line;
|
symbol.selectionRange.start.line = symbol.range.start.line;
|
||||||
symbol.documentation = parse_documentation(line);
|
symbol.documentation = parse_documentation_as_markdown(line);
|
||||||
symbol.uri = uri;
|
symbol.uri = uri;
|
||||||
symbol.script_path = path;
|
symbol.script_path = path;
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
||||||
r_symbol.range.end.line = MAX(p_func->body->end_line - 2, p_func->body->line);
|
r_symbol.range.end.line = MAX(p_func->body->end_line - 2, p_func->body->line);
|
||||||
r_symbol.range.end.character = lines[r_symbol.range.end.line].length();
|
r_symbol.range.end.character = lines[r_symbol.range.end.line].length();
|
||||||
r_symbol.selectionRange.start.line = r_symbol.range.start.line;
|
r_symbol.selectionRange.start.line = r_symbol.range.start.line;
|
||||||
r_symbol.documentation = GDScriptWorkspace::marked_documentation(parse_documentation(line));
|
r_symbol.documentation = parse_documentation_as_markdown(line);
|
||||||
r_symbol.uri = uri;
|
r_symbol.uri = uri;
|
||||||
r_symbol.script_path = path;
|
r_symbol.script_path = path;
|
||||||
|
|
||||||
|
@ -324,11 +324,67 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
||||||
if (var->datatype.kind != GDScriptParser::DataType::UNRESOLVED) {
|
if (var->datatype.kind != GDScriptParser::DataType::UNRESOLVED) {
|
||||||
symbol.detail += ": " + var->datatype.to_string();
|
symbol.detail += ": " + var->datatype.to_string();
|
||||||
}
|
}
|
||||||
symbol.documentation = GDScriptWorkspace::marked_documentation(parse_documentation(line));
|
symbol.documentation = parse_documentation_as_markdown(line);
|
||||||
r_symbol.children.push_back(symbol);
|
r_symbol.children.push_back(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ExtendGDScriptParser::marked_documentation(const String &p_bbcode) {
|
||||||
|
|
||||||
|
String markdown = p_bbcode.strip_edges();
|
||||||
|
|
||||||
|
Vector<String> lines = markdown.split("\n");
|
||||||
|
bool in_code_block = false;
|
||||||
|
int code_block_indent = -1;
|
||||||
|
|
||||||
|
markdown = "";
|
||||||
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
String line = lines[i];
|
||||||
|
int block_start = line.find("[codeblock]");
|
||||||
|
if (block_start != -1) {
|
||||||
|
code_block_indent = block_start;
|
||||||
|
in_code_block = true;
|
||||||
|
line = "'''gdscript";
|
||||||
|
line = "\n";
|
||||||
|
} else if (in_code_block) {
|
||||||
|
line = "\t" + line.substr(code_block_indent, line.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
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("[enum ", "`");
|
||||||
|
line = line.replace("[constant ", "`");
|
||||||
|
line = line.replace("[", "`");
|
||||||
|
line = line.replace("]", "`");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_code_block && i < lines.size() - 1) {
|
||||||
|
line += "\n\n";
|
||||||
|
} else if (i < lines.size() - 1) {
|
||||||
|
line += "\n";
|
||||||
|
}
|
||||||
|
markdown += line;
|
||||||
|
}
|
||||||
|
return markdown;
|
||||||
|
}
|
||||||
|
|
||||||
String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
|
String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
|
||||||
ERR_FAIL_INDEX_V(p_line, lines.size(), String());
|
ERR_FAIL_INDEX_V(p_line, lines.size(), String());
|
||||||
|
|
||||||
|
@ -353,19 +409,11 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
|
||||||
|
|
||||||
String line_comment = lines[i].strip_edges(true, false);
|
String line_comment = lines[i].strip_edges(true, false);
|
||||||
if (line_comment.begins_with("#")) {
|
if (line_comment.begins_with("#")) {
|
||||||
if (line_comment.length() > 1) {
|
line_comment = line_comment.substr(1, line_comment.length());
|
||||||
line_comment = line_comment.substr(1, line_comment.length());
|
if (p_docs_down) {
|
||||||
if (p_docs_down) {
|
doc_lines.push_back(line_comment);
|
||||||
doc_lines.push_back(line_comment);
|
|
||||||
} else {
|
|
||||||
doc_lines.push_front(line_comment);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (p_docs_down) {
|
doc_lines.push_front(line_comment);
|
||||||
doc_lines.push_back("");
|
|
||||||
} else {
|
|
||||||
doc_lines.push_front("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -374,8 +422,7 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
|
||||||
|
|
||||||
String doc;
|
String doc;
|
||||||
for (List<String>::Element *E = doc_lines.front(); E; E = E->next()) {
|
for (List<String>::Element *E = doc_lines.front(); E; E = E->next()) {
|
||||||
String content = E->get();
|
doc += E->get() + "\n";
|
||||||
doc += content + "\n";
|
|
||||||
}
|
}
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -496,6 +543,10 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(i
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ExtendGDScriptParser::parse_documentation_as_markdown(int p_line, bool p_docs_down) {
|
||||||
|
return marked_documentation(parse_documentation(p_line, p_docs_down));
|
||||||
|
}
|
||||||
|
|
||||||
const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int p_line) const {
|
const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int p_line) const {
|
||||||
if (p_line <= 0) {
|
if (p_line <= 0) {
|
||||||
return &class_symbol;
|
return &class_symbol;
|
||||||
|
|
|
@ -73,6 +73,11 @@ class ExtendGDScriptParser : public GDScriptParser {
|
||||||
|
|
||||||
Array member_completions;
|
Array member_completions;
|
||||||
|
|
||||||
|
String parse_documentation_as_markdown(int p_line, bool p_docs_down = false);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static String marked_documentation(const String &p_bbcode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_FORCE_INLINE_ const String &get_path() const { return path; }
|
_FORCE_INLINE_ const String &get_path() const { return path; }
|
||||||
_FORCE_INLINE_ const Vector<String> &get_lines() const { return lines; }
|
_FORCE_INLINE_ const Vector<String> &get_lines() const { return lines; }
|
||||||
|
|
|
@ -189,6 +189,10 @@ bool GDScriptLanguageProtocol::is_smart_resolve_enabled() const {
|
||||||
return bool(_EDITOR_GET("network/language_server/enable_smart_resolve"));
|
return bool(_EDITOR_GET("network/language_server/enable_smart_resolve"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
|
||||||
|
return bool(_EDITOR_GET("network/language_server/show_native_symbols_in_editor"));
|
||||||
|
}
|
||||||
|
|
||||||
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
|
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
|
||||||
server = NULL;
|
server = NULL;
|
||||||
singleton = this;
|
singleton = this;
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client = -1);
|
void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client = -1);
|
||||||
|
|
||||||
bool is_smart_resolve_enabled() const;
|
bool is_smart_resolve_enabled() const;
|
||||||
|
bool is_goto_native_symbols_enabled() const;
|
||||||
|
|
||||||
GDScriptLanguageProtocol();
|
GDScriptLanguageProtocol();
|
||||||
~GDScriptLanguageProtocol();
|
~GDScriptLanguageProtocol();
|
||||||
|
|
|
@ -38,6 +38,7 @@ GDScriptLanguageServer::GDScriptLanguageServer() {
|
||||||
thread_exit = false;
|
thread_exit = false;
|
||||||
_EDITOR_DEF("network/language_server/remote_port", 6008);
|
_EDITOR_DEF("network/language_server/remote_port", 6008);
|
||||||
_EDITOR_DEF("network/language_server/enable_smart_resolve", false);
|
_EDITOR_DEF("network/language_server/enable_smart_resolve", false);
|
||||||
|
_EDITOR_DEF("network/language_server/show_native_symbols_in_editor", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptLanguageServer::_notification(int p_what) {
|
void GDScriptLanguageServer::_notification(int p_what) {
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "../gdscript.h"
|
#include "../gdscript.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
#include "editor/plugins/script_text_editor.h"
|
||||||
#include "gdscript_extend_parser.h"
|
#include "gdscript_extend_parser.h"
|
||||||
#include "gdscript_language_protocol.h"
|
#include "gdscript_language_protocol.h"
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ void GDScriptTextDocument::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("colorPresentation"), &GDScriptTextDocument::colorPresentation);
|
ClassDB::bind_method(D_METHOD("colorPresentation"), &GDScriptTextDocument::colorPresentation);
|
||||||
ClassDB::bind_method(D_METHOD("hover"), &GDScriptTextDocument::hover);
|
ClassDB::bind_method(D_METHOD("hover"), &GDScriptTextDocument::hover);
|
||||||
ClassDB::bind_method(D_METHOD("definition"), &GDScriptTextDocument::definition);
|
ClassDB::bind_method(D_METHOD("definition"), &GDScriptTextDocument::definition);
|
||||||
|
ClassDB::bind_method(D_METHOD("show_native_symbol_in_editor"), &GDScriptTextDocument::show_native_symbol_in_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTextDocument::didOpen(const Variant &p_param) {
|
void GDScriptTextDocument::didOpen(const Variant &p_param) {
|
||||||
|
@ -324,6 +326,31 @@ Array GDScriptTextDocument::definition(const Dictionary &p_params) {
|
||||||
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)) {
|
if (file_checker->file_exists(path)) {
|
||||||
arr.push_back(location.to_json());
|
arr.push_back(location.to_json());
|
||||||
|
} else if (!symbol->native_class.empty() && GDScriptLanguageProtocol::get_singleton()->is_goto_native_symbols_enabled()) {
|
||||||
|
String id;
|
||||||
|
switch (symbol->kind) {
|
||||||
|
case lsp::SymbolKind::Class:
|
||||||
|
id = "class_name:" + symbol->name;
|
||||||
|
break;
|
||||||
|
case lsp::SymbolKind::Constant:
|
||||||
|
id = "class_constant:" + symbol->native_class + ":" + symbol->name;
|
||||||
|
break;
|
||||||
|
case lsp::SymbolKind::Property:
|
||||||
|
case lsp::SymbolKind::Variable:
|
||||||
|
id = "class_property:" + symbol->native_class + ":" + symbol->name;
|
||||||
|
break;
|
||||||
|
case lsp::SymbolKind::Enum:
|
||||||
|
id = "class_enum:" + symbol->native_class + ":" + symbol->name;
|
||||||
|
break;
|
||||||
|
case lsp::SymbolKind::Method:
|
||||||
|
case lsp::SymbolKind::Function:
|
||||||
|
id = "class_method:" + symbol->native_class + ":" + symbol->name;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
id = "class_global:" + symbol->native_class + ":" + symbol->name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
call_deferred("show_native_symbol_in_editor", id);
|
||||||
}
|
}
|
||||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||||
|
|
||||||
|
@ -332,12 +359,12 @@ Array GDScriptTextDocument::definition(const Dictionary &p_params) {
|
||||||
for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) {
|
for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) {
|
||||||
|
|
||||||
if (const lsp::DocumentSymbol *s = E->get()) {
|
if (const lsp::DocumentSymbol *s = E->get()) {
|
||||||
|
if (!s->uri.empty()) {
|
||||||
lsp::Location location;
|
lsp::Location location;
|
||||||
location.uri = s->uri;
|
location.uri = s->uri;
|
||||||
location.range = s->range;
|
location.range = s->range;
|
||||||
|
arr.push_back(location.to_json());
|
||||||
arr.push_back(location.to_json());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,3 +384,8 @@ void GDScriptTextDocument::sync_script_content(const String &p_uri, const String
|
||||||
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(p_uri);
|
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(p_uri);
|
||||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content);
|
GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) {
|
||||||
|
ScriptEditor::get_singleton()->call_deferred("_help_class_goto", p_symbol_id);
|
||||||
|
OS::get_singleton()->move_window_to_foreground();
|
||||||
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
void didChange(const Variant &p_param);
|
void didChange(const Variant &p_param);
|
||||||
|
|
||||||
void sync_script_content(const String &p_path, const String &p_content);
|
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;
|
Array native_member_completions;
|
||||||
|
|
||||||
|
|
|
@ -165,58 +165,6 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GDScriptWorkspace::marked_documentation(const String &p_bbcode) {
|
|
||||||
|
|
||||||
String markdown = p_bbcode.strip_edges();
|
|
||||||
|
|
||||||
Vector<String> lines = markdown.split("\n");
|
|
||||||
bool in_code_block = false;
|
|
||||||
int code_block_indent = -1;
|
|
||||||
|
|
||||||
markdown = "";
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
|
||||||
String line = lines[i];
|
|
||||||
int block_start = line.find("[codeblock]");
|
|
||||||
if (block_start != -1) {
|
|
||||||
code_block_indent = block_start;
|
|
||||||
in_code_block = true;
|
|
||||||
line = "'''gdscript";
|
|
||||||
line = "\n";
|
|
||||||
} else if (in_code_block) {
|
|
||||||
line = "\t" + line.substr(code_block_indent, line.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
markdown += line + "\n";
|
|
||||||
}
|
|
||||||
return markdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
Array GDScriptWorkspace::symbol(const Dictionary &p_params) {
|
Array GDScriptWorkspace::symbol(const Dictionary &p_params) {
|
||||||
String query = p_params["query"];
|
String query = p_params["query"];
|
||||||
Array arr;
|
Array arr;
|
||||||
|
@ -244,24 +192,26 @@ Error GDScriptWorkspace::initialize() {
|
||||||
lsp::DocumentSymbol class_symbol;
|
lsp::DocumentSymbol class_symbol;
|
||||||
String class_name = E->key();
|
String class_name = E->key();
|
||||||
class_symbol.name = class_name;
|
class_symbol.name = class_name;
|
||||||
|
class_symbol.native_class = class_name;
|
||||||
class_symbol.kind = lsp::SymbolKind::Class;
|
class_symbol.kind = lsp::SymbolKind::Class;
|
||||||
class_symbol.detail = String("<Native> class ") + class_name;
|
class_symbol.detail = String("<Native> class ") + class_name;
|
||||||
if (!class_data.inherits.empty()) {
|
if (!class_data.inherits.empty()) {
|
||||||
class_symbol.detail += " extends " + class_data.inherits;
|
class_symbol.detail += " extends " + class_data.inherits;
|
||||||
}
|
}
|
||||||
class_symbol.documentation = marked_documentation(class_data.brief_description) + "\n" + marked_documentation(class_data.description);
|
class_symbol.documentation = ExtendGDScriptParser::marked_documentation(class_data.brief_description) + "\n" + ExtendGDScriptParser::marked_documentation(class_data.description);
|
||||||
|
|
||||||
for (int i = 0; i < class_data.constants.size(); i++) {
|
for (int i = 0; i < class_data.constants.size(); i++) {
|
||||||
const DocData::ConstantDoc &const_data = class_data.constants[i];
|
const DocData::ConstantDoc &const_data = class_data.constants[i];
|
||||||
lsp::DocumentSymbol symbol;
|
lsp::DocumentSymbol symbol;
|
||||||
symbol.name = const_data.name;
|
symbol.name = const_data.name;
|
||||||
|
symbol.native_class = class_name;
|
||||||
symbol.kind = lsp::SymbolKind::Constant;
|
symbol.kind = lsp::SymbolKind::Constant;
|
||||||
symbol.detail = "const " + class_name + "." + const_data.name;
|
symbol.detail = "const " + class_name + "." + const_data.name;
|
||||||
if (const_data.enumeration.length()) {
|
if (const_data.enumeration.length()) {
|
||||||
symbol.detail += ": " + const_data.enumeration;
|
symbol.detail += ": " + const_data.enumeration;
|
||||||
}
|
}
|
||||||
symbol.detail += " = " + const_data.value;
|
symbol.detail += " = " + const_data.value;
|
||||||
symbol.documentation = marked_documentation(const_data.description);
|
symbol.documentation = ExtendGDScriptParser::marked_documentation(const_data.description);
|
||||||
class_symbol.children.push_back(symbol);
|
class_symbol.children.push_back(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +224,7 @@ Error GDScriptWorkspace::initialize() {
|
||||||
const DocData::PropertyDoc &data = class_data.properties[i];
|
const DocData::PropertyDoc &data = class_data.properties[i];
|
||||||
lsp::DocumentSymbol symbol;
|
lsp::DocumentSymbol symbol;
|
||||||
symbol.name = data.name;
|
symbol.name = data.name;
|
||||||
|
symbol.native_class = class_name;
|
||||||
symbol.kind = lsp::SymbolKind::Property;
|
symbol.kind = lsp::SymbolKind::Property;
|
||||||
symbol.detail = String(i >= theme_prop_start_idx ? "<Theme> var" : "var") + " " + class_name + "." + data.name;
|
symbol.detail = String(i >= theme_prop_start_idx ? "<Theme> var" : "var") + " " + class_name + "." + data.name;
|
||||||
if (data.enumeration.length()) {
|
if (data.enumeration.length()) {
|
||||||
|
@ -281,7 +232,7 @@ Error GDScriptWorkspace::initialize() {
|
||||||
} else {
|
} else {
|
||||||
symbol.detail += ": " + data.type;
|
symbol.detail += ": " + data.type;
|
||||||
}
|
}
|
||||||
symbol.documentation = marked_documentation(data.description);
|
symbol.documentation = ExtendGDScriptParser::marked_documentation(data.description);
|
||||||
class_symbol.children.push_back(symbol);
|
class_symbol.children.push_back(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +246,7 @@ Error GDScriptWorkspace::initialize() {
|
||||||
|
|
||||||
lsp::DocumentSymbol symbol;
|
lsp::DocumentSymbol symbol;
|
||||||
symbol.name = data.name;
|
symbol.name = data.name;
|
||||||
|
symbol.native_class = class_name;
|
||||||
symbol.kind = i >= signal_start_idx ? lsp::SymbolKind::Event : lsp::SymbolKind::Method;
|
symbol.kind = i >= signal_start_idx ? lsp::SymbolKind::Event : lsp::SymbolKind::Method;
|
||||||
|
|
||||||
String params = "";
|
String params = "";
|
||||||
|
@ -318,7 +270,7 @@ Error GDScriptWorkspace::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol.detail = "func " + class_name + "." + data.name + "(" + params + ") -> " + data.return_type;
|
symbol.detail = "func " + class_name + "." + data.name + "(" + params + ") -> " + data.return_type;
|
||||||
symbol.documentation = marked_documentation(data.description);
|
symbol.documentation = ExtendGDScriptParser::marked_documentation(data.description);
|
||||||
class_symbol.children.push_back(symbol);
|
class_symbol.children.push_back(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,6 @@ public:
|
||||||
|
|
||||||
Dictionary generate_script_api(const String &p_path);
|
Dictionary generate_script_api(const String &p_path);
|
||||||
|
|
||||||
static String marked_documentation(const String &p_bbcode);
|
|
||||||
|
|
||||||
GDScriptWorkspace();
|
GDScriptWorkspace();
|
||||||
~GDScriptWorkspace();
|
~GDScriptWorkspace();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1063,6 +1063,11 @@ struct DocumentSymbol {
|
||||||
*/
|
*/
|
||||||
String documentation;
|
String documentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class name for the native symbols
|
||||||
|
*/
|
||||||
|
String native_class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The kind of this symbol.
|
* The kind of this symbol.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue