mirror of
https://github.com/godotengine/godot.git
synced 2024-12-03 09:52:18 +08:00
Fix enumeration value of SymbolKind.
Add custom notification 'gdscript/show_native_symbol' to show native symbols in clients. Close client connections when stop gdscript-lsp
This commit is contained in:
parent
d66cce0215
commit
39813939fc
@ -153,7 +153,12 @@ Error GDScriptLanguageProtocol::start(int p_port) {
|
||||
}
|
||||
|
||||
void GDScriptLanguageProtocol::stop() {
|
||||
const int *ptr = NULL;
|
||||
while (ptr = clients.next(ptr)) {
|
||||
clients.get(*ptr)->close();
|
||||
}
|
||||
server->stop();
|
||||
clients.clear();
|
||||
}
|
||||
|
||||
void GDScriptLanguageProtocol::notify_all_clients(const String &p_method, const Variant &p_params) {
|
||||
|
@ -335,31 +335,35 @@ Array GDScriptTextDocument::definition(const Dictionary &p_params) {
|
||||
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 (!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;
|
||||
} else if (!symbol->native_class.empty()) {
|
||||
if (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 {
|
||||
GDScriptLanguageProtocol::get_singleton()->notify_client("gdscript/show_native_symbol", symbol->to_json(true));
|
||||
}
|
||||
call_deferred("show_native_symbol_in_editor", id);
|
||||
}
|
||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
|
||||
|
@ -983,32 +983,32 @@ struct CompletionList {
|
||||
* A symbol kind.
|
||||
*/
|
||||
namespace SymbolKind {
|
||||
static const int File = 1;
|
||||
static const int Module = 2;
|
||||
static const int Namespace = 3;
|
||||
static const int Package = 4;
|
||||
static const int Class = 5;
|
||||
static const int Method = 6;
|
||||
static const int Property = 7;
|
||||
static const int Field = 8;
|
||||
static const int Constructor = 9;
|
||||
static const int Enum = 10;
|
||||
static const int Interface = 11;
|
||||
static const int Function = 12;
|
||||
static const int Variable = 13;
|
||||
static const int Constant = 14;
|
||||
static const int String = 15;
|
||||
static const int Number = 16;
|
||||
static const int Boolean = 17;
|
||||
static const int Array = 18;
|
||||
static const int Object = 19;
|
||||
static const int Key = 20;
|
||||
static const int Null = 21;
|
||||
static const int EnumMember = 22;
|
||||
static const int Struct = 23;
|
||||
static const int Event = 24;
|
||||
static const int Operator = 25;
|
||||
static const int TypeParameter = 26;
|
||||
static const int File = 0;
|
||||
static const int Module = 1;
|
||||
static const int Namespace = 2;
|
||||
static const int Package = 3;
|
||||
static const int Class = 4;
|
||||
static const int Method = 5;
|
||||
static const int Property = 6;
|
||||
static const int Field = 7;
|
||||
static const int Constructor = 8;
|
||||
static const int Enum = 9;
|
||||
static const int Interface = 10;
|
||||
static const int Function = 11;
|
||||
static const int Variable = 12;
|
||||
static const int Constant = 13;
|
||||
static const int String = 14;
|
||||
static const int Number = 15;
|
||||
static const int Boolean = 16;
|
||||
static const int Array = 17;
|
||||
static const int Object = 18;
|
||||
static const int Key = 19;
|
||||
static const int Null = 20;
|
||||
static const int EnumMember = 21;
|
||||
static const int Struct = 22;
|
||||
static const int Event = 23;
|
||||
static const int Operator = 24;
|
||||
static const int TypeParameter = 25;
|
||||
}; // namespace SymbolKind
|
||||
|
||||
/**
|
||||
@ -1134,7 +1134,7 @@ struct DocumentSymbol {
|
||||
*/
|
||||
Vector<DocumentSymbol> children;
|
||||
|
||||
_FORCE_INLINE_ Dictionary to_json() const {
|
||||
_FORCE_INLINE_ Dictionary to_json(bool with_doc = false) const {
|
||||
Dictionary dict;
|
||||
dict["name"] = name;
|
||||
dict["detail"] = detail;
|
||||
@ -1142,10 +1142,14 @@ struct DocumentSymbol {
|
||||
dict["deprecated"] = deprecated;
|
||||
dict["range"] = range.to_json();
|
||||
dict["selectionRange"] = selectionRange.to_json();
|
||||
if (with_doc) {
|
||||
dict["documentation"] = documentation;
|
||||
dict["native_class"] = native_class;
|
||||
}
|
||||
Array arr;
|
||||
arr.resize(children.size());
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
arr[i] = children[i].to_json();
|
||||
arr[i] = children[i].to_json(with_doc);
|
||||
}
|
||||
dict["children"] = arr;
|
||||
return dict;
|
||||
|
Loading…
Reference in New Issue
Block a user