Style: Convert namespaces to PascalCase
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
|
||||
namespace core_bind {
|
||||
namespace CoreBind {
|
||||
|
||||
// Semaphore
|
||||
|
||||
@ -59,6 +59,6 @@ void OS::_bind_compatibility_methods() {
|
||||
ClassDB::bind_compatibility_method(D_METHOD("execute_with_pipe", "path", "arguments"), &OS::_execute_with_pipe_bind_compat_94434);
|
||||
}
|
||||
|
||||
} // namespace core_bind
|
||||
} // namespace CoreBind
|
||||
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
namespace core_bind {
|
||||
namespace CoreBind {
|
||||
|
||||
////// ResourceLoader //////
|
||||
|
||||
@ -1422,7 +1422,7 @@ void Thread::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(PRIORITY_HIGH);
|
||||
}
|
||||
|
||||
namespace special {
|
||||
namespace Special {
|
||||
|
||||
////// ClassDB //////
|
||||
|
||||
@ -1749,7 +1749,7 @@ void ClassDB::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(API_NONE);
|
||||
}
|
||||
|
||||
} // namespace special
|
||||
} // namespace Special
|
||||
|
||||
////// Engine //////
|
||||
|
||||
@ -2193,4 +2193,4 @@ void EngineDebugger::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("clear_breakpoints"), &EngineDebugger::clear_breakpoints);
|
||||
}
|
||||
|
||||
} // namespace core_bind
|
||||
} // namespace CoreBind
|
||||
|
||||
@ -41,7 +41,7 @@ class MainLoop;
|
||||
template <typename T>
|
||||
class TypedArray;
|
||||
|
||||
namespace core_bind {
|
||||
namespace CoreBind {
|
||||
|
||||
class ResourceLoader : public Object {
|
||||
GDCLASS(ResourceLoader, Object);
|
||||
@ -457,7 +457,7 @@ public:
|
||||
static void set_thread_safety_checks_enabled(bool p_enabled);
|
||||
};
|
||||
|
||||
namespace special {
|
||||
namespace Special {
|
||||
|
||||
class ClassDB : public Object {
|
||||
GDCLASS(ClassDB, Object);
|
||||
@ -523,7 +523,7 @@ public:
|
||||
~ClassDB() {}
|
||||
};
|
||||
|
||||
} // namespace special
|
||||
} // namespace Special
|
||||
|
||||
class Engine : public Object {
|
||||
GDCLASS(Engine, Object);
|
||||
@ -651,21 +651,21 @@ public:
|
||||
~EngineDebugger();
|
||||
};
|
||||
|
||||
} // namespace core_bind
|
||||
} // namespace CoreBind
|
||||
|
||||
VARIANT_ENUM_CAST(core_bind::ResourceLoader::ThreadLoadStatus);
|
||||
VARIANT_ENUM_CAST(core_bind::ResourceLoader::CacheMode);
|
||||
VARIANT_ENUM_CAST(CoreBind::ResourceLoader::ThreadLoadStatus);
|
||||
VARIANT_ENUM_CAST(CoreBind::ResourceLoader::CacheMode);
|
||||
|
||||
VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags);
|
||||
VARIANT_BITFIELD_CAST(CoreBind::ResourceSaver::SaverFlags);
|
||||
|
||||
VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver);
|
||||
VARIANT_ENUM_CAST(core_bind::OS::SystemDir);
|
||||
VARIANT_ENUM_CAST(core_bind::OS::StdHandleType);
|
||||
VARIANT_ENUM_CAST(CoreBind::OS::RenderingDriver);
|
||||
VARIANT_ENUM_CAST(CoreBind::OS::SystemDir);
|
||||
VARIANT_ENUM_CAST(CoreBind::OS::StdHandleType);
|
||||
|
||||
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation);
|
||||
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyJoinType);
|
||||
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyEndType);
|
||||
VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyBooleanOperation);
|
||||
VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyJoinType);
|
||||
VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyEndType);
|
||||
|
||||
VARIANT_ENUM_CAST(core_bind::Thread::Priority);
|
||||
VARIANT_ENUM_CAST(CoreBind::Thread::Priority);
|
||||
|
||||
VARIANT_ENUM_CAST(core_bind::special::ClassDB::APIType);
|
||||
VARIANT_ENUM_CAST(CoreBind::Special::ClassDB::APIType);
|
||||
|
||||
@ -905,8 +905,8 @@ Ref<Resource> ResourceLoader::_load_complete_inner(LoadToken &p_load_token, Erro
|
||||
}
|
||||
}
|
||||
if (!import_thread) { // Main thread is blocked by initial resource reimport, do not wait.
|
||||
core_bind::Semaphore done;
|
||||
MessageQueue::get_main_singleton()->push_callable(callable_mp(&done, &core_bind::Semaphore::post).bind(1));
|
||||
CoreBind::Semaphore done;
|
||||
MessageQueue::get_main_singleton()->push_callable(callable_mp(&done, &CoreBind::Semaphore::post).bind(1));
|
||||
done.wait();
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include "core/object/worker_thread_pool.h"
|
||||
#include "core/os/thread.h"
|
||||
|
||||
namespace core_bind {
|
||||
namespace CoreBind {
|
||||
class ResourceLoader;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ typedef void (*ResourceLoadedCallback)(Ref<Resource> p_resource, const String &p
|
||||
|
||||
class ResourceLoader {
|
||||
friend class LoadToken;
|
||||
friend class core_bind::ResourceLoader;
|
||||
friend class CoreBind::ResourceLoader;
|
||||
|
||||
enum {
|
||||
MAX_LOADERS = 64
|
||||
|
||||
@ -92,19 +92,19 @@ static Ref<GDExtensionResourceLoader> resource_loader_gdextension;
|
||||
static Ref<ResourceFormatSaverJSON> resource_saver_json;
|
||||
static Ref<ResourceFormatLoaderJSON> resource_loader_json;
|
||||
|
||||
static core_bind::ResourceLoader *_resource_loader = nullptr;
|
||||
static core_bind::ResourceSaver *_resource_saver = nullptr;
|
||||
static core_bind::OS *_os = nullptr;
|
||||
static core_bind::Engine *_engine = nullptr;
|
||||
static core_bind::special::ClassDB *_classdb = nullptr;
|
||||
static core_bind::Marshalls *_marshalls = nullptr;
|
||||
static core_bind::EngineDebugger *_engine_debugger = nullptr;
|
||||
static CoreBind::ResourceLoader *_resource_loader = nullptr;
|
||||
static CoreBind::ResourceSaver *_resource_saver = nullptr;
|
||||
static CoreBind::OS *_os = nullptr;
|
||||
static CoreBind::Engine *_engine = nullptr;
|
||||
static CoreBind::Special::ClassDB *_classdb = nullptr;
|
||||
static CoreBind::Marshalls *_marshalls = nullptr;
|
||||
static CoreBind::EngineDebugger *_engine_debugger = nullptr;
|
||||
|
||||
static IP *ip = nullptr;
|
||||
static Time *_time = nullptr;
|
||||
|
||||
static core_bind::Geometry2D *_geometry_2d = nullptr;
|
||||
static core_bind::Geometry3D *_geometry_3d = nullptr;
|
||||
static CoreBind::Geometry2D *_geometry_2d = nullptr;
|
||||
static CoreBind::Geometry3D *_geometry_3d = nullptr;
|
||||
|
||||
static WorkerThreadPool *worker_thread_pool = nullptr;
|
||||
|
||||
@ -251,9 +251,9 @@ void register_core_types() {
|
||||
|
||||
GDREGISTER_ABSTRACT_CLASS(FileAccess);
|
||||
GDREGISTER_ABSTRACT_CLASS(DirAccess);
|
||||
GDREGISTER_CLASS(core_bind::Thread);
|
||||
GDREGISTER_CLASS(core_bind::Mutex);
|
||||
GDREGISTER_CLASS(core_bind::Semaphore);
|
||||
GDREGISTER_CLASS(CoreBind::Thread);
|
||||
GDREGISTER_CLASS(CoreBind::Mutex);
|
||||
GDREGISTER_CLASS(CoreBind::Semaphore);
|
||||
|
||||
GDREGISTER_CLASS(XMLParser);
|
||||
GDREGISTER_CLASS(JSON);
|
||||
@ -293,16 +293,16 @@ void register_core_types() {
|
||||
|
||||
ip = IP::create();
|
||||
|
||||
_geometry_2d = memnew(core_bind::Geometry2D);
|
||||
_geometry_3d = memnew(core_bind::Geometry3D);
|
||||
_geometry_2d = memnew(CoreBind::Geometry2D);
|
||||
_geometry_3d = memnew(CoreBind::Geometry3D);
|
||||
|
||||
_resource_loader = memnew(core_bind::ResourceLoader);
|
||||
_resource_saver = memnew(core_bind::ResourceSaver);
|
||||
_os = memnew(core_bind::OS);
|
||||
_engine = memnew(core_bind::Engine);
|
||||
_classdb = memnew(core_bind::special::ClassDB);
|
||||
_marshalls = memnew(core_bind::Marshalls);
|
||||
_engine_debugger = memnew(core_bind::EngineDebugger);
|
||||
_resource_loader = memnew(CoreBind::ResourceLoader);
|
||||
_resource_saver = memnew(CoreBind::ResourceSaver);
|
||||
_os = memnew(CoreBind::OS);
|
||||
_engine = memnew(CoreBind::Engine);
|
||||
_classdb = memnew(CoreBind::Special::ClassDB);
|
||||
_marshalls = memnew(CoreBind::Marshalls);
|
||||
_engine_debugger = memnew(CoreBind::EngineDebugger);
|
||||
|
||||
GDREGISTER_NATIVE_STRUCT(ObjectID, "uint64_t id = 0");
|
||||
GDREGISTER_NATIVE_STRUCT(AudioFrame, "float left;float right");
|
||||
@ -324,14 +324,14 @@ void register_core_settings() {
|
||||
}
|
||||
|
||||
void register_early_core_singletons() {
|
||||
GDREGISTER_CLASS(core_bind::Engine);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Engine", core_bind::Engine::get_singleton()));
|
||||
GDREGISTER_CLASS(CoreBind::Engine);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Engine", CoreBind::Engine::get_singleton()));
|
||||
|
||||
GDREGISTER_CLASS(ProjectSettings);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
|
||||
|
||||
GDREGISTER_CLASS(core_bind::OS);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("OS", core_bind::OS::get_singleton()));
|
||||
GDREGISTER_CLASS(CoreBind::OS);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("OS", CoreBind::OS::get_singleton()));
|
||||
|
||||
GDREGISTER_CLASS(Time);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton()));
|
||||
@ -341,29 +341,29 @@ void register_core_singletons() {
|
||||
OS::get_singleton()->benchmark_begin_measure("Core", "Register Singletons");
|
||||
|
||||
GDREGISTER_ABSTRACT_CLASS(IP);
|
||||
GDREGISTER_CLASS(core_bind::Geometry2D);
|
||||
GDREGISTER_CLASS(core_bind::Geometry3D);
|
||||
GDREGISTER_CLASS(core_bind::ResourceLoader);
|
||||
GDREGISTER_CLASS(core_bind::ResourceSaver);
|
||||
GDREGISTER_CLASS(core_bind::special::ClassDB);
|
||||
GDREGISTER_CLASS(core_bind::Marshalls);
|
||||
GDREGISTER_CLASS(CoreBind::Geometry2D);
|
||||
GDREGISTER_CLASS(CoreBind::Geometry3D);
|
||||
GDREGISTER_CLASS(CoreBind::ResourceLoader);
|
||||
GDREGISTER_CLASS(CoreBind::ResourceSaver);
|
||||
GDREGISTER_CLASS(CoreBind::Special::ClassDB);
|
||||
GDREGISTER_CLASS(CoreBind::Marshalls);
|
||||
GDREGISTER_CLASS(TranslationServer);
|
||||
GDREGISTER_ABSTRACT_CLASS(Input);
|
||||
GDREGISTER_CLASS(InputMap);
|
||||
GDREGISTER_CLASS(Expression);
|
||||
GDREGISTER_CLASS(core_bind::EngineDebugger);
|
||||
GDREGISTER_CLASS(CoreBind::EngineDebugger);
|
||||
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton(), "IP"));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry2D", core_bind::Geometry2D::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry3D", core_bind::Geometry3D::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", core_bind::ResourceLoader::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", core_bind::ResourceSaver::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry2D", CoreBind::Geometry2D::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry3D", CoreBind::Geometry3D::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", CoreBind::ResourceLoader::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", CoreBind::ResourceSaver::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ClassDB", _classdb));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", core_bind::Marshalls::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", CoreBind::Marshalls::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", core_bind::EngineDebugger::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", CoreBind::EngineDebugger::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("GDExtensionManager", GDExtensionManager::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceUID", ResourceUID::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("WorkerThreadPool", worker_thread_pool));
|
||||
|
||||
@ -209,8 +209,8 @@ struct GetTypeInfo<T *, std::enable_if_t<std::is_base_of_v<Object, T>>> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace godot {
|
||||
namespace details {
|
||||
namespace GodotTypeInfo {
|
||||
namespace Internal {
|
||||
inline String enum_qualified_name_to_class_info_name(const String &p_qualified_name) {
|
||||
Vector<String> parts = p_qualified_name.split("::", false);
|
||||
if (parts.size() <= 2) {
|
||||
@ -219,8 +219,8 @@ inline String enum_qualified_name_to_class_info_name(const String &p_qualified_n
|
||||
// Contains namespace. We only want the class and enum names.
|
||||
return parts[parts.size() - 2] + "." + parts[parts.size() - 1];
|
||||
}
|
||||
} // namespace details
|
||||
} // namespace godot
|
||||
} // namespace Internal
|
||||
} // namespace GodotTypeInfo
|
||||
|
||||
#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \
|
||||
template <> \
|
||||
@ -229,7 +229,7 @@ inline String enum_qualified_name_to_class_info_name(const String &p_qualified_n
|
||||
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, \
|
||||
godot::details::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
} \
|
||||
};
|
||||
|
||||
@ -278,7 +278,7 @@ struct is_zero_constructible<BitField<T>> : std::true_type {};
|
||||
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
|
||||
godot::details::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
} \
|
||||
}; \
|
||||
template <> \
|
||||
@ -287,7 +287,7 @@ struct is_zero_constructible<BitField<T>> : std::true_type {};
|
||||
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
|
||||
godot::details::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \
|
||||
} \
|
||||
};
|
||||
|
||||
|
||||
@ -44,8 +44,8 @@ int get_indent_size() {
|
||||
}
|
||||
}
|
||||
|
||||
lsp::Position GodotPosition::to_lsp(const Vector<String> &p_lines) const {
|
||||
lsp::Position res;
|
||||
LSP::Position GodotPosition::to_lsp(const Vector<String> &p_lines) const {
|
||||
LSP::Position res;
|
||||
|
||||
// Special case: `line = 0` -> root class (range covers everything).
|
||||
if (line <= 0) {
|
||||
@ -89,7 +89,7 @@ lsp::Position GodotPosition::to_lsp(const Vector<String> &p_lines) const {
|
||||
return res;
|
||||
}
|
||||
|
||||
GodotPosition GodotPosition::from_lsp(const lsp::Position p_pos, const Vector<String> &p_lines) {
|
||||
GodotPosition GodotPosition::from_lsp(const LSP::Position p_pos, const Vector<String> &p_lines) {
|
||||
GodotPosition res(p_pos.line + 1, p_pos.character + 1);
|
||||
|
||||
// Line outside of actual text is valid (-> pos/cursor at end of text).
|
||||
@ -113,14 +113,14 @@ GodotPosition GodotPosition::from_lsp(const lsp::Position p_pos, const Vector<St
|
||||
return res;
|
||||
}
|
||||
|
||||
lsp::Range GodotRange::to_lsp(const Vector<String> &p_lines) const {
|
||||
lsp::Range res;
|
||||
LSP::Range GodotRange::to_lsp(const Vector<String> &p_lines) const {
|
||||
LSP::Range res;
|
||||
res.start = start.to_lsp(p_lines);
|
||||
res.end = end.to_lsp(p_lines);
|
||||
return res;
|
||||
}
|
||||
|
||||
GodotRange GodotRange::from_lsp(const lsp::Range &p_range, const Vector<String> &p_lines) {
|
||||
GodotRange GodotRange::from_lsp(const LSP::Range &p_range, const Vector<String> &p_lines) {
|
||||
GodotPosition start = GodotPosition::from_lsp(p_range.start, p_lines);
|
||||
GodotPosition end = GodotPosition::from_lsp(p_range.end, p_lines);
|
||||
return GodotRange(start, end);
|
||||
@ -131,13 +131,13 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
|
||||
const List<ParserError> &parser_errors = get_errors();
|
||||
for (const ParserError &error : parser_errors) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Error;
|
||||
LSP::Diagnostic diagnostic;
|
||||
diagnostic.severity = LSP::DiagnosticSeverity::Error;
|
||||
diagnostic.message = error.message;
|
||||
diagnostic.source = "gdscript";
|
||||
diagnostic.code = -1;
|
||||
lsp::Range range;
|
||||
lsp::Position pos;
|
||||
LSP::Range range;
|
||||
LSP::Position pos;
|
||||
const PackedStringArray line_array = get_lines();
|
||||
int line = CLAMP(LINE_NUMBER_TO_INDEX(error.line), 0, line_array.size() - 1);
|
||||
const String &line_text = line_array[line];
|
||||
@ -152,13 +152,13 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
|
||||
const List<GDScriptWarning> &parser_warnings = get_warnings();
|
||||
for (const GDScriptWarning &warning : parser_warnings) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Warning;
|
||||
LSP::Diagnostic diagnostic;
|
||||
diagnostic.severity = LSP::DiagnosticSeverity::Warning;
|
||||
diagnostic.message = "(" + warning.get_name() + "): " + warning.get_message();
|
||||
diagnostic.source = "gdscript";
|
||||
diagnostic.code = warning.code;
|
||||
lsp::Range range;
|
||||
lsp::Position pos;
|
||||
LSP::Range range;
|
||||
LSP::Position pos;
|
||||
int line = LINE_NUMBER_TO_INDEX(warning.start_line);
|
||||
const String &line_text = get_lines()[line];
|
||||
pos.line = line;
|
||||
@ -178,14 +178,14 @@ void ExtendGDScriptParser::update_symbols() {
|
||||
parse_class_symbol(gdclass, class_symbol);
|
||||
|
||||
for (int i = 0; i < class_symbol.children.size(); i++) {
|
||||
const lsp::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
const LSP::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
members.insert(symbol.name, &symbol);
|
||||
|
||||
// Cache level one inner classes.
|
||||
if (symbol.kind == lsp::SymbolKind::Class) {
|
||||
if (symbol.kind == LSP::SymbolKind::Class) {
|
||||
ClassMembers inner_class;
|
||||
for (int j = 0; j < symbol.children.size(); j++) {
|
||||
const lsp::DocumentSymbol &s = symbol.children[j];
|
||||
const LSP::DocumentSymbol &s = symbol.children[j];
|
||||
inner_class.insert(s.name, &s);
|
||||
}
|
||||
inner_classes.insert(symbol.name, inner_class);
|
||||
@ -215,7 +215,7 @@ void ExtendGDScriptParser::update_document_links(const String &p_code) {
|
||||
}
|
||||
if (exists) {
|
||||
String value = const_val;
|
||||
lsp::DocumentLink link;
|
||||
LSP::DocumentLink link;
|
||||
link.target = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_uri(scr_path);
|
||||
link.range = GodotRange(GodotPosition(token.start_line, token.start_column), GodotPosition(token.end_line, token.end_column)).to_lsp(lines);
|
||||
document_links.push_back(link);
|
||||
@ -225,13 +225,13 @@ void ExtendGDScriptParser::update_document_links(const String &p_code) {
|
||||
}
|
||||
}
|
||||
|
||||
lsp::Range ExtendGDScriptParser::range_of_node(const GDScriptParser::Node *p_node) const {
|
||||
LSP::Range ExtendGDScriptParser::range_of_node(const GDScriptParser::Node *p_node) const {
|
||||
GodotPosition start(p_node->start_line, p_node->start_column);
|
||||
GodotPosition end(p_node->end_line, p_node->end_column);
|
||||
return GodotRange(start, end).to_lsp(lines);
|
||||
}
|
||||
|
||||
void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p_class, lsp::DocumentSymbol &r_symbol) {
|
||||
void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p_class, LSP::DocumentSymbol &r_symbol) {
|
||||
const String uri = get_uri();
|
||||
|
||||
r_symbol.uri = uri;
|
||||
@ -241,7 +241,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
if (r_symbol.name.is_empty()) {
|
||||
r_symbol.name = path.get_file();
|
||||
}
|
||||
r_symbol.kind = lsp::SymbolKind::Class;
|
||||
r_symbol.kind = LSP::SymbolKind::Class;
|
||||
r_symbol.deprecated = false;
|
||||
r_symbol.range = range_of_node(p_class);
|
||||
if (p_class->identifier) {
|
||||
@ -276,9 +276,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
|
||||
switch (m.type) {
|
||||
case ClassNode::Member::VARIABLE: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = m.variable->identifier->name;
|
||||
symbol.kind = m.variable->property == VariableNode::PROP_NONE ? lsp::SymbolKind::Variable : lsp::SymbolKind::Property;
|
||||
symbol.kind = m.variable->property == VariableNode::PROP_NONE ? LSP::SymbolKind::Variable : LSP::SymbolKind::Property;
|
||||
symbol.deprecated = false;
|
||||
symbol.range = range_of_node(m.variable);
|
||||
symbol.selectionRange = range_of_node(m.variable->identifier);
|
||||
@ -299,20 +299,20 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
|
||||
if (m.variable->initializer && m.variable->initializer->type == GDScriptParser::Node::LAMBDA) {
|
||||
GDScriptParser::LambdaNode *lambda_node = (GDScriptParser::LambdaNode *)m.variable->initializer;
|
||||
lsp::DocumentSymbol lambda;
|
||||
LSP::DocumentSymbol lambda;
|
||||
parse_function_symbol(lambda_node->function, lambda);
|
||||
// Merge lambda into current variable.
|
||||
symbol.children.append_array(lambda.children);
|
||||
}
|
||||
|
||||
if (m.variable->getter && m.variable->getter->type == GDScriptParser::Node::FUNCTION) {
|
||||
lsp::DocumentSymbol get_symbol;
|
||||
LSP::DocumentSymbol get_symbol;
|
||||
parse_function_symbol(m.variable->getter, get_symbol);
|
||||
get_symbol.local = true;
|
||||
symbol.children.push_back(get_symbol);
|
||||
}
|
||||
if (m.variable->setter && m.variable->setter->type == GDScriptParser::Node::FUNCTION) {
|
||||
lsp::DocumentSymbol set_symbol;
|
||||
LSP::DocumentSymbol set_symbol;
|
||||
parse_function_symbol(m.variable->setter, set_symbol);
|
||||
set_symbol.local = true;
|
||||
symbol.children.push_back(set_symbol);
|
||||
@ -321,10 +321,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::CONSTANT: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
|
||||
symbol.name = m.constant->identifier->name;
|
||||
symbol.kind = lsp::SymbolKind::Constant;
|
||||
symbol.kind = LSP::SymbolKind::Constant;
|
||||
symbol.deprecated = false;
|
||||
symbol.range = range_of_node(m.constant);
|
||||
symbol.selectionRange = range_of_node(m.constant->identifier);
|
||||
@ -361,9 +361,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::SIGNAL: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = m.signal->identifier->name;
|
||||
symbol.kind = lsp::SymbolKind::Event;
|
||||
symbol.kind = LSP::SymbolKind::Event;
|
||||
symbol.deprecated = false;
|
||||
symbol.range = range_of_node(m.signal);
|
||||
symbol.selectionRange = range_of_node(m.signal->identifier);
|
||||
@ -380,9 +380,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
symbol.detail += ")";
|
||||
|
||||
for (GDScriptParser::ParameterNode *param : m.signal->parameters) {
|
||||
lsp::DocumentSymbol param_symbol;
|
||||
LSP::DocumentSymbol param_symbol;
|
||||
param_symbol.name = param->identifier->name;
|
||||
param_symbol.kind = lsp::SymbolKind::Variable;
|
||||
param_symbol.kind = LSP::SymbolKind::Variable;
|
||||
param_symbol.deprecated = false;
|
||||
param_symbol.local = true;
|
||||
param_symbol.range = range_of_node(param);
|
||||
@ -398,10 +398,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::ENUM_VALUE: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
|
||||
symbol.name = m.enum_value.identifier->name;
|
||||
symbol.kind = lsp::SymbolKind::EnumMember;
|
||||
symbol.kind = LSP::SymbolKind::EnumMember;
|
||||
symbol.deprecated = false;
|
||||
symbol.range.start = GodotPosition(m.enum_value.line, m.enum_value.leftmost_column).to_lsp(lines);
|
||||
symbol.range.end = GodotPosition(m.enum_value.line, m.enum_value.rightmost_column).to_lsp(lines);
|
||||
@ -415,9 +415,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::ENUM: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = m.m_enum->identifier->name;
|
||||
symbol.kind = lsp::SymbolKind::Enum;
|
||||
symbol.kind = LSP::SymbolKind::Enum;
|
||||
symbol.range = range_of_node(m.m_enum);
|
||||
symbol.selectionRange = range_of_node(m.m_enum->identifier);
|
||||
symbol.documentation = m.m_enum->doc_data.description;
|
||||
@ -434,10 +434,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
symbol.detail += "}";
|
||||
|
||||
for (GDScriptParser::EnumNode::Value value : m.m_enum->values) {
|
||||
lsp::DocumentSymbol child;
|
||||
LSP::DocumentSymbol child;
|
||||
|
||||
child.name = value.identifier->name;
|
||||
child.kind = lsp::SymbolKind::EnumMember;
|
||||
child.kind = LSP::SymbolKind::EnumMember;
|
||||
child.deprecated = false;
|
||||
child.range.start = GodotPosition(value.line, value.leftmost_column).to_lsp(lines);
|
||||
child.range.end = GodotPosition(value.line, value.rightmost_column).to_lsp(lines);
|
||||
@ -454,12 +454,12 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::FUNCTION: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
parse_function_symbol(m.function, symbol);
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
case ClassNode::Member::CLASS: {
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
parse_class_symbol(m.m_class, symbol);
|
||||
r_symbol.children.push_back(symbol);
|
||||
} break;
|
||||
@ -471,13 +471,13 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
|
||||
}
|
||||
}
|
||||
|
||||
void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNode *p_func, lsp::DocumentSymbol &r_symbol) {
|
||||
void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNode *p_func, LSP::DocumentSymbol &r_symbol) {
|
||||
const String uri = get_uri();
|
||||
|
||||
bool is_named = p_func->identifier != nullptr;
|
||||
|
||||
r_symbol.name = is_named ? p_func->identifier->name : "";
|
||||
r_symbol.kind = (p_func->is_static || p_func->source_lambda != nullptr) ? lsp::SymbolKind::Function : lsp::SymbolKind::Method;
|
||||
r_symbol.kind = (p_func->is_static || p_func->source_lambda != nullptr) ? LSP::SymbolKind::Function : LSP::SymbolKind::Method;
|
||||
r_symbol.detail = "func";
|
||||
if (is_named) {
|
||||
r_symbol.detail += " " + String(p_func->identifier->name);
|
||||
@ -570,9 +570,9 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
||||
const GDScriptParser::SuiteNode *suite_node = N->get();
|
||||
for (int i = 0; i < suite_node->locals.size(); i++) {
|
||||
const SuiteNode::Local &local = suite_node->locals[i];
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = local.name;
|
||||
symbol.kind = local.type == SuiteNode::Local::CONSTANT ? lsp::SymbolKind::Constant : lsp::SymbolKind::Variable;
|
||||
symbol.kind = local.type == SuiteNode::Local::CONSTANT ? LSP::SymbolKind::Constant : LSP::SymbolKind::Variable;
|
||||
switch (local.type) {
|
||||
case SuiteNode::Local::CONSTANT:
|
||||
symbol.range = range_of_node(local.constant);
|
||||
@ -583,7 +583,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
||||
symbol.selectionRange = range_of_node(local.variable->identifier);
|
||||
if (local.variable->initializer && local.variable->initializer->type == GDScriptParser::Node::LAMBDA) {
|
||||
GDScriptParser::LambdaNode *lambda_node = (GDScriptParser::LambdaNode *)local.variable->initializer;
|
||||
lsp::DocumentSymbol lambda;
|
||||
LSP::DocumentSymbol lambda;
|
||||
parse_function_symbol(lambda_node->function, lambda);
|
||||
// Merge lambda into current variable.
|
||||
// -> Only interested in new variables, not lambda itself.
|
||||
@ -629,7 +629,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
||||
}
|
||||
}
|
||||
|
||||
String ExtendGDScriptParser::get_text_for_completion(const lsp::Position &p_cursor) const {
|
||||
String ExtendGDScriptParser::get_text_for_completion(const LSP::Position &p_cursor) const {
|
||||
String longthing;
|
||||
int len = lines.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
@ -649,7 +649,7 @@ String ExtendGDScriptParser::get_text_for_completion(const lsp::Position &p_curs
|
||||
return longthing;
|
||||
}
|
||||
|
||||
String ExtendGDScriptParser::get_text_for_lookup_symbol(const lsp::Position &p_cursor, const String &p_symbol, bool p_func_required) const {
|
||||
String ExtendGDScriptParser::get_text_for_lookup_symbol(const LSP::Position &p_cursor, const String &p_symbol, bool p_func_required) const {
|
||||
String longthing;
|
||||
int len = lines.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
@ -687,7 +687,7 @@ String ExtendGDScriptParser::get_text_for_lookup_symbol(const lsp::Position &p_c
|
||||
return longthing;
|
||||
}
|
||||
|
||||
String ExtendGDScriptParser::get_identifier_under_position(const lsp::Position &p_position, lsp::Range &r_range) const {
|
||||
String ExtendGDScriptParser::get_identifier_under_position(const LSP::Position &p_position, LSP::Range &r_range) const {
|
||||
ERR_FAIL_INDEX_V(p_position.line, lines.size(), "");
|
||||
String line = lines[p_position.line];
|
||||
if (line.is_empty()) {
|
||||
@ -709,7 +709,7 @@ String ExtendGDScriptParser::get_identifier_under_position(const lsp::Position &
|
||||
// -> Move position to previous character if:
|
||||
// * Position not on valid identifier char.
|
||||
// * Prev position is valid identifier char.
|
||||
lsp::Position pos = p_position;
|
||||
LSP::Position pos = p_position;
|
||||
if (
|
||||
pos.character >= line.length() // Cursor at end of line.
|
||||
|| (!is_ascii_identifier_char(line[pos.character]) // Not on valid identifier char.
|
||||
@ -753,8 +753,8 @@ String ExtendGDScriptParser::get_uri() const {
|
||||
return GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_uri(path);
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(int p_line, const lsp::DocumentSymbol &p_parent, const String &p_symbol_name) const {
|
||||
const lsp::DocumentSymbol *ret = nullptr;
|
||||
const LSP::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(int p_line, const LSP::DocumentSymbol &p_parent, const String &p_symbol_name) const {
|
||||
const LSP::DocumentSymbol *ret = nullptr;
|
||||
if (p_line < p_parent.range.start.line) {
|
||||
return ret;
|
||||
} else if (p_parent.range.start.line == p_line && (p_symbol_name.is_empty() || p_parent.name == p_symbol_name)) {
|
||||
@ -770,7 +770,7 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(i
|
||||
return ret;
|
||||
}
|
||||
|
||||
Error ExtendGDScriptParser::get_left_function_call(const lsp::Position &p_position, lsp::Position &r_func_pos, int &r_arg_index) const {
|
||||
Error ExtendGDScriptParser::get_left_function_call(const LSP::Position &p_position, LSP::Position &r_func_pos, int &r_arg_index) const {
|
||||
ERR_FAIL_INDEX_V(p_position.line, lines.size(), ERR_INVALID_PARAMETER);
|
||||
|
||||
int bracket_stack = 0;
|
||||
@ -814,22 +814,22 @@ Error ExtendGDScriptParser::get_left_function_call(const lsp::Position &p_positi
|
||||
return ERR_METHOD_NOT_FOUND;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int p_line, const String &p_symbol_name) const {
|
||||
const LSP::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int p_line, const String &p_symbol_name) const {
|
||||
if (p_line <= 0) {
|
||||
return &class_symbol;
|
||||
}
|
||||
return search_symbol_defined_at_line(p_line, class_symbol, p_symbol_name);
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String &p_name, const String &p_subclass) const {
|
||||
const LSP::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String &p_name, const String &p_subclass) const {
|
||||
if (p_subclass.is_empty()) {
|
||||
const lsp::DocumentSymbol *const *ptr = members.getptr(p_name);
|
||||
const LSP::DocumentSymbol *const *ptr = members.getptr(p_name);
|
||||
if (ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
} else {
|
||||
if (const ClassMembers *_class = inner_classes.getptr(p_subclass)) {
|
||||
const lsp::DocumentSymbol *const *ptr = _class->getptr(p_name);
|
||||
const LSP::DocumentSymbol *const *ptr = _class->getptr(p_name);
|
||||
if (ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
@ -839,15 +839,15 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const List<lsp::DocumentLink> &ExtendGDScriptParser::get_document_links() const {
|
||||
const List<LSP::DocumentLink> &ExtendGDScriptParser::get_document_links() const {
|
||||
return document_links;
|
||||
}
|
||||
|
||||
const Array &ExtendGDScriptParser::get_member_completions() {
|
||||
if (member_completions.is_empty()) {
|
||||
for (const KeyValue<String, const lsp::DocumentSymbol *> &E : members) {
|
||||
const lsp::DocumentSymbol *symbol = E.value;
|
||||
lsp::CompletionItem item = symbol->make_completion_item();
|
||||
for (const KeyValue<String, const LSP::DocumentSymbol *> &E : members) {
|
||||
const LSP::DocumentSymbol *symbol = E.value;
|
||||
LSP::CompletionItem item = symbol->make_completion_item();
|
||||
item.data = JOIN_SYMBOLS(path, E.key);
|
||||
member_completions.push_back(item.to_json());
|
||||
}
|
||||
@ -855,9 +855,9 @@ const Array &ExtendGDScriptParser::get_member_completions() {
|
||||
for (const KeyValue<String, ClassMembers> &E : inner_classes) {
|
||||
const ClassMembers *inner_class = &E.value;
|
||||
|
||||
for (const KeyValue<String, const lsp::DocumentSymbol *> &F : *inner_class) {
|
||||
const lsp::DocumentSymbol *symbol = F.value;
|
||||
lsp::CompletionItem item = symbol->make_completion_item();
|
||||
for (const KeyValue<String, const LSP::DocumentSymbol *> &F : *inner_class) {
|
||||
const LSP::DocumentSymbol *symbol = F.value;
|
||||
LSP::CompletionItem item = symbol->make_completion_item();
|
||||
item.data = JOIN_SYMBOLS(path, JOIN_SYMBOLS(E.key, F.key));
|
||||
member_completions.push_back(item.to_json());
|
||||
}
|
||||
@ -883,7 +883,7 @@ Dictionary ExtendGDScriptParser::dump_function_api(const GDScriptParser::Functio
|
||||
}
|
||||
parameters.push_back(arg);
|
||||
}
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(p_func->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(p_func->start_line))) {
|
||||
func["signature"] = symbol->detail;
|
||||
func["description"] = symbol->documentation;
|
||||
}
|
||||
@ -906,7 +906,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
class_api["extends_file"] = String(p_class->extends_path);
|
||||
class_api["icon"] = String(p_class->icon_path);
|
||||
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(p_class->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(p_class->start_line))) {
|
||||
class_api["signature"] = symbol->detail;
|
||||
class_api["description"] = symbol->documentation;
|
||||
}
|
||||
@ -929,7 +929,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
api["name"] = m.constant->identifier->name;
|
||||
api["value"] = m.constant->initializer->reduced_value;
|
||||
api["data_type"] = m.constant->get_datatype().to_string();
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.constant->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.constant->start_line))) {
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
@ -940,7 +940,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
api["name"] = m.enum_value.identifier->name;
|
||||
api["value"] = m.enum_value.value;
|
||||
api["data_type"] = m.get_datatype().to_string();
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.enum_value.line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.enum_value.line))) {
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
@ -956,7 +956,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
api["name"] = m.m_enum->identifier->name;
|
||||
api["value"] = enum_dict;
|
||||
api["data_type"] = m.get_datatype().to_string();
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.m_enum->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.m_enum->start_line))) {
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
@ -970,7 +970,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
api["setter"] = m.variable->setter ? ("@" + String(m.variable->identifier->name) + "_setter") : (m.variable->setter_pointer != nullptr ? String(m.variable->setter_pointer->name) : String());
|
||||
api["getter"] = m.variable->getter ? ("@" + String(m.variable->identifier->name) + "_getter") : (m.variable->getter_pointer != nullptr ? String(m.variable->getter_pointer->name) : String());
|
||||
api["export"] = m.variable->exported;
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.variable->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.variable->start_line))) {
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
@ -984,7 +984,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
pars.append(String(m.signal->parameters[j]->identifier->name));
|
||||
}
|
||||
api["arguments"] = pars;
|
||||
if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.signal->start_line))) {
|
||||
if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.signal->start_line))) {
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
|
||||
@ -50,12 +50,12 @@
|
||||
#define JOIN_SYMBOLS(p_path, name) ((p_path) + SYMBOL_SEPARATOR + (name))
|
||||
#endif
|
||||
|
||||
typedef HashMap<String, const lsp::DocumentSymbol *> ClassMembers;
|
||||
typedef HashMap<String, const LSP::DocumentSymbol *> ClassMembers;
|
||||
|
||||
/**
|
||||
* Represents a Position as used by GDScript Parser. Used for conversion to and from `lsp::Position`.
|
||||
* Represents a Position as used by GDScript Parser. Used for conversion to and from `LSP::Position`.
|
||||
*
|
||||
* Difference to `lsp::Position`:
|
||||
* Difference to `LSP::Position`:
|
||||
* * Line & Char/column: 1-based
|
||||
* * LSP: both 0-based
|
||||
* * Tabs are expanded to columns using tab size (`text_editor/behavior/indent/size`).
|
||||
@ -79,8 +79,8 @@ struct GodotPosition {
|
||||
GodotPosition(int p_line, int p_column) :
|
||||
line(p_line), column(p_column) {}
|
||||
|
||||
lsp::Position to_lsp(const Vector<String> &p_lines) const;
|
||||
static GodotPosition from_lsp(const lsp::Position p_pos, const Vector<String> &p_lines);
|
||||
LSP::Position to_lsp(const Vector<String> &p_lines) const;
|
||||
static GodotPosition from_lsp(const LSP::Position p_pos, const Vector<String> &p_lines);
|
||||
|
||||
bool operator==(const GodotPosition &p_other) const {
|
||||
return line == p_other.line && column == p_other.column;
|
||||
@ -98,8 +98,8 @@ struct GodotRange {
|
||||
GodotRange(GodotPosition p_start, GodotPosition p_end) :
|
||||
start(p_start), end(p_end) {}
|
||||
|
||||
lsp::Range to_lsp(const Vector<String> &p_lines) const;
|
||||
static GodotRange from_lsp(const lsp::Range &p_range, const Vector<String> &p_lines);
|
||||
LSP::Range to_lsp(const Vector<String> &p_lines) const;
|
||||
static GodotRange from_lsp(const LSP::Range &p_range, const Vector<String> &p_lines);
|
||||
|
||||
bool operator==(const GodotRange &p_other) const {
|
||||
return start == p_other.start && end == p_other.end;
|
||||
@ -114,41 +114,41 @@ class ExtendGDScriptParser : public GDScriptParser {
|
||||
String path;
|
||||
Vector<String> lines;
|
||||
|
||||
lsp::DocumentSymbol class_symbol;
|
||||
Vector<lsp::Diagnostic> diagnostics;
|
||||
List<lsp::DocumentLink> document_links;
|
||||
LSP::DocumentSymbol class_symbol;
|
||||
Vector<LSP::Diagnostic> diagnostics;
|
||||
List<LSP::DocumentLink> document_links;
|
||||
ClassMembers members;
|
||||
HashMap<String, ClassMembers> inner_classes;
|
||||
|
||||
lsp::Range range_of_node(const GDScriptParser::Node *p_node) const;
|
||||
LSP::Range range_of_node(const GDScriptParser::Node *p_node) const;
|
||||
|
||||
void update_diagnostics();
|
||||
|
||||
void update_symbols();
|
||||
void update_document_links(const String &p_code);
|
||||
void parse_class_symbol(const GDScriptParser::ClassNode *p_class, lsp::DocumentSymbol &r_symbol);
|
||||
void parse_function_symbol(const GDScriptParser::FunctionNode *p_func, lsp::DocumentSymbol &r_symbol);
|
||||
void parse_class_symbol(const GDScriptParser::ClassNode *p_class, LSP::DocumentSymbol &r_symbol);
|
||||
void parse_function_symbol(const GDScriptParser::FunctionNode *p_func, LSP::DocumentSymbol &r_symbol);
|
||||
|
||||
Dictionary dump_function_api(const GDScriptParser::FunctionNode *p_func) const;
|
||||
Dictionary dump_class_api(const GDScriptParser::ClassNode *p_class) const;
|
||||
|
||||
const lsp::DocumentSymbol *search_symbol_defined_at_line(int p_line, const lsp::DocumentSymbol &p_parent, const String &p_symbol_name = "") const;
|
||||
const LSP::DocumentSymbol *search_symbol_defined_at_line(int p_line, const LSP::DocumentSymbol &p_parent, const String &p_symbol_name = "") const;
|
||||
|
||||
Array member_completions;
|
||||
|
||||
public:
|
||||
_FORCE_INLINE_ const String &get_path() const { return path; }
|
||||
_FORCE_INLINE_ const Vector<String> &get_lines() const { return lines; }
|
||||
_FORCE_INLINE_ const lsp::DocumentSymbol &get_symbols() const { return class_symbol; }
|
||||
_FORCE_INLINE_ const Vector<lsp::Diagnostic> &get_diagnostics() const { return diagnostics; }
|
||||
_FORCE_INLINE_ const LSP::DocumentSymbol &get_symbols() const { return class_symbol; }
|
||||
_FORCE_INLINE_ const Vector<LSP::Diagnostic> &get_diagnostics() const { return diagnostics; }
|
||||
_FORCE_INLINE_ const ClassMembers &get_members() const { return members; }
|
||||
_FORCE_INLINE_ const HashMap<String, ClassMembers> &get_inner_classes() const { return inner_classes; }
|
||||
|
||||
Error get_left_function_call(const lsp::Position &p_position, lsp::Position &r_func_pos, int &r_arg_index) const;
|
||||
Error get_left_function_call(const LSP::Position &p_position, LSP::Position &r_func_pos, int &r_arg_index) const;
|
||||
|
||||
String get_text_for_completion(const lsp::Position &p_cursor) const;
|
||||
String get_text_for_lookup_symbol(const lsp::Position &p_cursor, const String &p_symbol = "", bool p_func_required = false) const;
|
||||
String get_identifier_under_position(const lsp::Position &p_position, lsp::Range &r_range) const;
|
||||
String get_text_for_completion(const LSP::Position &p_cursor) const;
|
||||
String get_text_for_lookup_symbol(const LSP::Position &p_cursor, const String &p_symbol = "", bool p_func_required = false) const;
|
||||
String get_identifier_under_position(const LSP::Position &p_position, LSP::Range &r_range) const;
|
||||
String get_uri() const;
|
||||
|
||||
/**
|
||||
@ -159,9 +159,9 @@ public:
|
||||
* -> Without `p_symbol_name`: returns `handle_arg`. Even if parameter (`arg`) is wanted.
|
||||
* With `p_symbol_name`: symbol name MUST match `p_symbol_name`: returns `arg`.
|
||||
*/
|
||||
const lsp::DocumentSymbol *get_symbol_defined_at_line(int p_line, const String &p_symbol_name = "") const;
|
||||
const lsp::DocumentSymbol *get_member_symbol(const String &p_name, const String &p_subclass = "") const;
|
||||
const List<lsp::DocumentLink> &get_document_links() const;
|
||||
const LSP::DocumentSymbol *get_symbol_defined_at_line(int p_line, const String &p_symbol_name = "") const;
|
||||
const LSP::DocumentSymbol *get_member_symbol(const String &p_name, const String &p_subclass = "") const;
|
||||
const List<LSP::DocumentLink> &get_document_links() const;
|
||||
|
||||
const Array &get_member_completions();
|
||||
Dictionary generate_api() const;
|
||||
|
||||
@ -171,7 +171,7 @@ void GDScriptLanguageProtocol::_bind_methods() {
|
||||
}
|
||||
|
||||
Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
|
||||
lsp::InitializeResult ret;
|
||||
LSP::InitializeResult ret;
|
||||
|
||||
String root_uri = p_params["rootUri"];
|
||||
String root = p_params["rootPath"];
|
||||
@ -213,11 +213,11 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
void GDScriptLanguageProtocol::initialized(const Variant &p_params) {
|
||||
lsp::GodotCapabilities capabilities;
|
||||
LSP::GodotCapabilities capabilities;
|
||||
|
||||
DocTools *doc = EditorHelp::get_doc_data();
|
||||
for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) {
|
||||
lsp::GodotNativeClassInfo gdclass;
|
||||
LSP::GodotNativeClassInfo gdclass;
|
||||
gdclass.name = E.value.name;
|
||||
gdclass.class_doc = &(E.value);
|
||||
if (ClassDB::ClassInfo *ptr = ClassDB::classes.getptr(StringName(E.value.name))) {
|
||||
|
||||
@ -63,7 +63,7 @@ void GDScriptTextDocument::_bind_methods() {
|
||||
}
|
||||
|
||||
void GDScriptTextDocument::didOpen(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc = load_document_item(p_param);
|
||||
LSP::TextDocumentItem doc = load_document_item(p_param);
|
||||
sync_script_content(doc.uri, doc.text);
|
||||
}
|
||||
|
||||
@ -73,11 +73,11 @@ void GDScriptTextDocument::didClose(const Variant &p_param) {
|
||||
}
|
||||
|
||||
void GDScriptTextDocument::didChange(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc = load_document_item(p_param);
|
||||
LSP::TextDocumentItem doc = load_document_item(p_param);
|
||||
Dictionary dict = p_param;
|
||||
Array contentChanges = dict["contentChanges"];
|
||||
for (int i = 0; i < contentChanges.size(); ++i) {
|
||||
lsp::TextDocumentContentChangeEvent evt;
|
||||
LSP::TextDocumentContentChangeEvent evt;
|
||||
evt.load(contentChanges[i]);
|
||||
doc.text = evt.text;
|
||||
}
|
||||
@ -85,7 +85,7 @@ void GDScriptTextDocument::didChange(const Variant &p_param) {
|
||||
}
|
||||
|
||||
void GDScriptTextDocument::willSaveWaitUntil(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc = load_document_item(p_param);
|
||||
LSP::TextDocumentItem doc = load_document_item(p_param);
|
||||
|
||||
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(doc.uri);
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
@ -95,7 +95,7 @@ void GDScriptTextDocument::willSaveWaitUntil(const Variant &p_param) {
|
||||
}
|
||||
|
||||
void GDScriptTextDocument::didSave(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc = load_document_item(p_param);
|
||||
LSP::TextDocumentItem doc = load_document_item(p_param);
|
||||
Dictionary dict = p_param;
|
||||
String text = dict["text"];
|
||||
|
||||
@ -126,14 +126,14 @@ void GDScriptTextDocument::reload_script(Ref<GDScript> p_to_reload_script) {
|
||||
ScriptEditor::get_singleton()->trigger_live_script_reload(p_to_reload_script->get_path());
|
||||
}
|
||||
|
||||
lsp::TextDocumentItem GDScriptTextDocument::load_document_item(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc;
|
||||
LSP::TextDocumentItem GDScriptTextDocument::load_document_item(const Variant &p_param) {
|
||||
LSP::TextDocumentItem doc;
|
||||
Dictionary params = p_param;
|
||||
doc.load(params["textDocument"]);
|
||||
return doc;
|
||||
}
|
||||
|
||||
void GDScriptTextDocument::notify_client_show_symbol(const lsp::DocumentSymbol *symbol) {
|
||||
void GDScriptTextDocument::notify_client_show_symbol(const LSP::DocumentSymbol *symbol) {
|
||||
ERR_FAIL_NULL(symbol);
|
||||
GDScriptLanguageProtocol::get_singleton()->notify_client("gdscript/show_native_symbol", symbol->to_json(true));
|
||||
}
|
||||
@ -143,9 +143,9 @@ void GDScriptTextDocument::initialize() {
|
||||
for (const KeyValue<StringName, ClassMembers> &E : GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members) {
|
||||
const ClassMembers &members = E.value;
|
||||
|
||||
for (const KeyValue<String, const lsp::DocumentSymbol *> &F : members) {
|
||||
const lsp::DocumentSymbol *symbol = members.get(F.key);
|
||||
lsp::CompletionItem item = symbol->make_completion_item();
|
||||
for (const KeyValue<String, const LSP::DocumentSymbol *> &F : members) {
|
||||
const LSP::DocumentSymbol *symbol = members.get(F.key);
|
||||
LSP::CompletionItem item = symbol->make_completion_item();
|
||||
item.data = JOIN_SYMBOLS(String(E.key), F.key);
|
||||
native_member_completions.push_back(item.to_json());
|
||||
}
|
||||
@ -156,10 +156,10 @@ void GDScriptTextDocument::initialize() {
|
||||
Variant GDScriptTextDocument::nativeSymbol(const Dictionary &p_params) {
|
||||
Variant ret;
|
||||
|
||||
lsp::NativeSymbolInspectParams params;
|
||||
LSP::NativeSymbolInspectParams params;
|
||||
params.load(p_params);
|
||||
|
||||
if (const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_native_symbol(params)) {
|
||||
if (const LSP::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_native_symbol(params)) {
|
||||
ret = symbol->to_json(true);
|
||||
notify_client_show_symbol(symbol);
|
||||
}
|
||||
@ -173,7 +173,7 @@ Array GDScriptTextDocument::documentSymbol(const Dictionary &p_params) {
|
||||
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(uri);
|
||||
Array arr;
|
||||
if (HashMap<String, ExtendGDScriptParser *>::ConstIterator parser = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.find(path)) {
|
||||
lsp::DocumentSymbol symbol = parser->value->get_symbols();
|
||||
LSP::DocumentSymbol symbol = parser->value->get_symbols();
|
||||
arr.push_back(symbol.to_json(true));
|
||||
}
|
||||
return arr;
|
||||
@ -182,7 +182,7 @@ Array GDScriptTextDocument::documentSymbol(const Dictionary &p_params) {
|
||||
Array GDScriptTextDocument::completion(const Dictionary &p_params) {
|
||||
Array arr;
|
||||
|
||||
lsp::CompletionParams params;
|
||||
LSP::CompletionParams params;
|
||||
params.load(p_params);
|
||||
Dictionary request_data = params.to_json();
|
||||
|
||||
@ -194,41 +194,41 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
|
||||
arr.resize(options.size());
|
||||
|
||||
for (const ScriptLanguage::CodeCompletionOption &option : options) {
|
||||
lsp::CompletionItem item;
|
||||
LSP::CompletionItem item;
|
||||
item.label = option.display;
|
||||
item.data = request_data;
|
||||
item.insertText = option.insert_text;
|
||||
|
||||
switch (option.kind) {
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_ENUM:
|
||||
item.kind = lsp::CompletionItemKind::Enum;
|
||||
item.kind = LSP::CompletionItemKind::Enum;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_CLASS:
|
||||
item.kind = lsp::CompletionItemKind::Class;
|
||||
item.kind = LSP::CompletionItemKind::Class;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_MEMBER:
|
||||
item.kind = lsp::CompletionItemKind::Property;
|
||||
item.kind = LSP::CompletionItemKind::Property;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION:
|
||||
item.kind = lsp::CompletionItemKind::Method;
|
||||
item.kind = LSP::CompletionItemKind::Method;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL:
|
||||
item.kind = lsp::CompletionItemKind::Event;
|
||||
item.kind = LSP::CompletionItemKind::Event;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT:
|
||||
item.kind = lsp::CompletionItemKind::Constant;
|
||||
item.kind = LSP::CompletionItemKind::Constant;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE:
|
||||
item.kind = lsp::CompletionItemKind::Variable;
|
||||
item.kind = LSP::CompletionItemKind::Variable;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH:
|
||||
item.kind = lsp::CompletionItemKind::File;
|
||||
item.kind = LSP::CompletionItemKind::File;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH:
|
||||
item.kind = lsp::CompletionItemKind::Snippet;
|
||||
item.kind = LSP::CompletionItemKind::Snippet;
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT:
|
||||
item.kind = lsp::CompletionItemKind::Text;
|
||||
item.kind = LSP::CompletionItemKind::Text;
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
@ -242,7 +242,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
Dictionary GDScriptTextDocument::rename(const Dictionary &p_params) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.load(p_params);
|
||||
String new_name = p_params["newName"];
|
||||
|
||||
@ -250,11 +250,11 @@ Dictionary GDScriptTextDocument::rename(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
Variant GDScriptTextDocument::prepareRename(const Dictionary &p_params) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.load(p_params);
|
||||
|
||||
lsp::DocumentSymbol symbol;
|
||||
lsp::Range range;
|
||||
LSP::DocumentSymbol symbol;
|
||||
LSP::Range range;
|
||||
if (GDScriptLanguageProtocol::get_singleton()->get_workspace()->can_rename(params, symbol, range)) {
|
||||
return Variant(range.to_json());
|
||||
}
|
||||
@ -266,16 +266,16 @@ Variant GDScriptTextDocument::prepareRename(const Dictionary &p_params) {
|
||||
Array GDScriptTextDocument::references(const Dictionary &p_params) {
|
||||
Array res;
|
||||
|
||||
lsp::ReferenceParams params;
|
||||
LSP::ReferenceParams 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) {
|
||||
Vector<lsp::Location> usages = GDScriptLanguageProtocol::get_singleton()->get_workspace()->find_all_usages(*symbol);
|
||||
Vector<LSP::Location> usages = GDScriptLanguageProtocol::get_singleton()->get_workspace()->find_all_usages(*symbol);
|
||||
res.resize(usages.size());
|
||||
int declaration_adjustment = 0;
|
||||
for (int i = 0; i < usages.size(); i++) {
|
||||
lsp::Location usage = usages[i];
|
||||
LSP::Location usage = usages[i];
|
||||
if (!params.context.includeDeclaration && usage.range == symbol->range) {
|
||||
declaration_adjustment++;
|
||||
continue;
|
||||
@ -292,17 +292,17 @@ Array GDScriptTextDocument::references(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
|
||||
lsp::CompletionItem item;
|
||||
LSP::CompletionItem item;
|
||||
item.load(p_params);
|
||||
|
||||
lsp::CompletionParams params;
|
||||
LSP::CompletionParams params;
|
||||
Variant data = p_params["data"];
|
||||
|
||||
const lsp::DocumentSymbol *symbol = nullptr;
|
||||
const LSP::DocumentSymbol *symbol = nullptr;
|
||||
|
||||
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.is_string()) {
|
||||
String query = data;
|
||||
@ -318,7 +318,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
if (const ClassMembers *members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members.getptr(class_name)) {
|
||||
if (const lsp::DocumentSymbol *const *member = members->getptr(member_name)) {
|
||||
if (const LSP::DocumentSymbol *const *member = members->getptr(member_name)) {
|
||||
symbol = *member;
|
||||
}
|
||||
}
|
||||
@ -335,15 +335,15 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
|
||||
item.documentation = symbol->render();
|
||||
}
|
||||
|
||||
if (item.kind == lsp::CompletionItemKind::Event) {
|
||||
if (params.context.triggerKind == lsp::CompletionTriggerKind::TriggerCharacter && (params.context.triggerCharacter == "(")) {
|
||||
if (item.kind == LSP::CompletionItemKind::Event) {
|
||||
if (params.context.triggerKind == LSP::CompletionTriggerKind::TriggerCharacter && (params.context.triggerCharacter == "(")) {
|
||||
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
|
||||
item.insertText = item.label.quote(quote_style);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.kind == lsp::CompletionItemKind::Method) {
|
||||
bool is_trigger_character = params.context.triggerKind == lsp::CompletionTriggerKind::TriggerCharacter;
|
||||
if (item.kind == LSP::CompletionItemKind::Method) {
|
||||
bool is_trigger_character = params.context.triggerKind == LSP::CompletionTriggerKind::TriggerCharacter;
|
||||
bool is_quote_character = params.context.triggerCharacter == "\"" || params.context.triggerCharacter == "'";
|
||||
|
||||
if (is_trigger_character && is_quote_character && item.insertText.is_quoted()) {
|
||||
@ -367,12 +367,12 @@ Array GDScriptTextDocument::codeLens(const Dictionary &p_params) {
|
||||
Array GDScriptTextDocument::documentLink(const Dictionary &p_params) {
|
||||
Array ret;
|
||||
|
||||
lsp::DocumentLinkParams params;
|
||||
LSP::DocumentLinkParams params;
|
||||
params.load(p_params);
|
||||
|
||||
List<lsp::DocumentLink> links;
|
||||
List<LSP::DocumentLink> links;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_document_links(params.textDocument.uri, links);
|
||||
for (const lsp::DocumentLink &E : links) {
|
||||
for (const LSP::DocumentLink &E : links) {
|
||||
ret.push_back(E.to_json());
|
||||
}
|
||||
return ret;
|
||||
@ -384,12 +384,12 @@ Array GDScriptTextDocument::colorPresentation(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
|
||||
lsp::TextDocumentPositionParams 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;
|
||||
LSP::Hover hover;
|
||||
hover.contents = symbol->render();
|
||||
hover.range.start = params.position;
|
||||
hover.range.end = params.position;
|
||||
@ -398,10 +398,10 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
|
||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
Dictionary ret;
|
||||
Array contents;
|
||||
List<const lsp::DocumentSymbol *> list;
|
||||
List<const LSP::DocumentSymbol *> list;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list);
|
||||
for (const lsp::DocumentSymbol *&E : list) {
|
||||
if (const lsp::DocumentSymbol *s = E) {
|
||||
for (const LSP::DocumentSymbol *&E : list) {
|
||||
if (const LSP::DocumentSymbol *s = E) {
|
||||
contents.push_back(s->render().value);
|
||||
}
|
||||
}
|
||||
@ -413,38 +413,38 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
|
||||
}
|
||||
|
||||
Array GDScriptTextDocument::definition(const Dictionary &p_params) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.load(p_params);
|
||||
List<const lsp::DocumentSymbol *> symbols;
|
||||
List<const LSP::DocumentSymbol *> symbols;
|
||||
Array arr = find_symbols(params, symbols);
|
||||
return arr;
|
||||
}
|
||||
|
||||
Variant GDScriptTextDocument::declaration(const Dictionary &p_params) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.load(p_params);
|
||||
List<const lsp::DocumentSymbol *> symbols;
|
||||
List<const LSP::DocumentSymbol *> symbols;
|
||||
Array arr = find_symbols(params, symbols);
|
||||
if (arr.is_empty() && !symbols.is_empty() && !symbols.front()->get()->native_class.is_empty()) { // Find a native symbol
|
||||
const lsp::DocumentSymbol *symbol = symbols.front()->get();
|
||||
const LSP::DocumentSymbol *symbol = symbols.front()->get();
|
||||
if (GDScriptLanguageProtocol::get_singleton()->is_goto_native_symbols_enabled()) {
|
||||
String id;
|
||||
switch (symbol->kind) {
|
||||
case lsp::SymbolKind::Class:
|
||||
case LSP::SymbolKind::Class:
|
||||
id = "class_name:" + symbol->name;
|
||||
break;
|
||||
case lsp::SymbolKind::Constant:
|
||||
case LSP::SymbolKind::Constant:
|
||||
id = "class_constant:" + symbol->native_class + ":" + symbol->name;
|
||||
break;
|
||||
case lsp::SymbolKind::Property:
|
||||
case lsp::SymbolKind::Variable:
|
||||
case LSP::SymbolKind::Property:
|
||||
case LSP::SymbolKind::Variable:
|
||||
id = "class_property:" + symbol->native_class + ":" + symbol->name;
|
||||
break;
|
||||
case lsp::SymbolKind::Enum:
|
||||
case LSP::SymbolKind::Enum:
|
||||
id = "class_enum:" + symbol->native_class + ":" + symbol->name;
|
||||
break;
|
||||
case lsp::SymbolKind::Method:
|
||||
case lsp::SymbolKind::Function:
|
||||
case LSP::SymbolKind::Method:
|
||||
case LSP::SymbolKind::Function:
|
||||
id = "class_method:" + symbol->native_class + ":" + symbol->name;
|
||||
break;
|
||||
default:
|
||||
@ -462,10 +462,10 @@ Variant GDScriptTextDocument::declaration(const Dictionary &p_params) {
|
||||
Variant GDScriptTextDocument::signatureHelp(const Dictionary &p_params) {
|
||||
Variant ret;
|
||||
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.load(p_params);
|
||||
|
||||
lsp::SignatureHelp s;
|
||||
LSP::SignatureHelp s;
|
||||
if (OK == GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_signature(params, s)) {
|
||||
ret = s.to_json();
|
||||
}
|
||||
@ -488,11 +488,11 @@ void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_i
|
||||
DisplayServer::get_singleton()->window_move_to_foreground();
|
||||
}
|
||||
|
||||
Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams &p_location, List<const lsp::DocumentSymbol *> &r_list) {
|
||||
Array GDScriptTextDocument::find_symbols(const LSP::TextDocumentPositionParams &p_location, List<const LSP::DocumentSymbol *> &r_list) {
|
||||
Array arr;
|
||||
const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(p_location);
|
||||
const LSP::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(p_location);
|
||||
if (symbol) {
|
||||
lsp::Location location;
|
||||
LSP::Location location;
|
||||
location.uri = symbol->uri;
|
||||
location.range = symbol->selectionRange;
|
||||
const String &path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(symbol->uri);
|
||||
@ -501,12 +501,12 @@ Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams &
|
||||
}
|
||||
r_list.push_back(symbol);
|
||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
List<const lsp::DocumentSymbol *> list;
|
||||
List<const LSP::DocumentSymbol *> list;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(p_location, list);
|
||||
for (const lsp::DocumentSymbol *&E : list) {
|
||||
if (const lsp::DocumentSymbol *s = E) {
|
||||
for (const LSP::DocumentSymbol *&E : list) {
|
||||
if (const LSP::DocumentSymbol *s = E) {
|
||||
if (!s->uri.is_empty()) {
|
||||
lsp::Location location;
|
||||
LSP::Location location;
|
||||
location.uri = s->uri;
|
||||
location.range = s->selectionRange;
|
||||
arr.push_back(location.to_json());
|
||||
|
||||
@ -57,9 +57,9 @@ protected:
|
||||
Array native_member_completions;
|
||||
|
||||
private:
|
||||
Array find_symbols(const lsp::TextDocumentPositionParams &p_location, List<const lsp::DocumentSymbol *> &r_list);
|
||||
lsp::TextDocumentItem load_document_item(const Variant &p_param);
|
||||
void notify_client_show_symbol(const lsp::DocumentSymbol *symbol);
|
||||
Array find_symbols(const LSP::TextDocumentPositionParams &p_location, List<const LSP::DocumentSymbol *> &r_list);
|
||||
LSP::TextDocumentItem load_document_item(const Variant &p_param);
|
||||
void notify_client_show_symbol(const LSP::DocumentSymbol *symbol);
|
||||
|
||||
public:
|
||||
Variant nativeSymbol(const Dictionary &p_params);
|
||||
|
||||
@ -89,7 +89,7 @@ void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStr
|
||||
}
|
||||
function_body += ":\n\tpass # Replace with function body.\n";
|
||||
|
||||
lsp::TextEdit text_edit;
|
||||
LSP::TextEdit text_edit;
|
||||
|
||||
if (first_class != -1) {
|
||||
function_body += "\n\n";
|
||||
@ -100,7 +100,7 @@ void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStr
|
||||
|
||||
String uri = get_file_uri(scr->get_path());
|
||||
|
||||
lsp::ApplyWorkspaceEditParams params;
|
||||
LSP::ApplyWorkspaceEditParams params;
|
||||
params.edit.add_edit(uri, text_edit);
|
||||
|
||||
GDScriptLanguageProtocol::get_singleton()->request_client("workspace/applyEdit", params.to_json());
|
||||
@ -137,19 +137,19 @@ void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
|
||||
}
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_class, const String &p_member) const {
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_class, const String &p_member) const {
|
||||
StringName class_name = p_class;
|
||||
StringName empty;
|
||||
|
||||
while (class_name != empty) {
|
||||
if (HashMap<StringName, lsp::DocumentSymbol>::ConstIterator E = native_symbols.find(class_name)) {
|
||||
const lsp::DocumentSymbol &class_symbol = E->value;
|
||||
if (HashMap<StringName, LSP::DocumentSymbol>::ConstIterator E = native_symbols.find(class_name)) {
|
||||
const LSP::DocumentSymbol &class_symbol = E->value;
|
||||
|
||||
if (p_member.is_empty()) {
|
||||
return &class_symbol;
|
||||
} else {
|
||||
for (int i = 0; i < class_symbol.children.size(); i++) {
|
||||
const lsp::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
const LSP::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
if (symbol.name == p_member) {
|
||||
return &symbol;
|
||||
}
|
||||
@ -162,7 +162,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_path) const {
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_path) const {
|
||||
HashMap<String, ExtendGDScriptParser *>::ConstIterator S = scripts.find(p_path);
|
||||
if (S) {
|
||||
return &(S->value->get_symbols());
|
||||
@ -170,9 +170,9 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::get_parameter_symbol(const lsp::DocumentSymbol *p_parent, const String &symbol_identifier) {
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::get_parameter_symbol(const LSP::DocumentSymbol *p_parent, const String &symbol_identifier) {
|
||||
for (int i = 0; i < p_parent->children.size(); ++i) {
|
||||
const lsp::DocumentSymbol *parameter_symbol = &p_parent->children[i];
|
||||
const LSP::DocumentSymbol *parameter_symbol = &p_parent->children[i];
|
||||
if (!parameter_symbol->detail.is_empty() && parameter_symbol->name == symbol_identifier) {
|
||||
return parameter_symbol;
|
||||
}
|
||||
@ -181,11 +181,11 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_parameter_symbol(const lsp::Do
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const lsp::Position p_position) {
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const LSP::Position p_position) {
|
||||
// Go down and pick closest `DocumentSymbol` with `p_symbol_identifier`.
|
||||
|
||||
const lsp::DocumentSymbol *current = &p_parser->get_symbols();
|
||||
const lsp::DocumentSymbol *best_match = nullptr;
|
||||
const LSP::DocumentSymbol *current = &p_parser->get_symbols();
|
||||
const LSP::DocumentSymbol *best_match = nullptr;
|
||||
|
||||
while (current) {
|
||||
if (current->name == p_symbol_identifier) {
|
||||
@ -197,9 +197,9 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_local_symbol_at(const ExtendGD
|
||||
best_match = current;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *parent = current;
|
||||
const LSP::DocumentSymbol *parent = current;
|
||||
current = nullptr;
|
||||
for (const lsp::DocumentSymbol &child : parent->children) {
|
||||
for (const LSP::DocumentSymbol &child : parent->children) {
|
||||
if (child.range.contains(p_position)) {
|
||||
current = &child;
|
||||
break;
|
||||
@ -287,11 +287,11 @@ Error GDScriptWorkspace::initialize() {
|
||||
DocTools *doc = EditorHelp::get_doc_data();
|
||||
for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) {
|
||||
const DocData::ClassDoc &class_data = E.value;
|
||||
lsp::DocumentSymbol class_symbol;
|
||||
LSP::DocumentSymbol class_symbol;
|
||||
String class_name = E.key;
|
||||
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;
|
||||
if (!class_data.inherits.is_empty()) {
|
||||
class_symbol.detail += " extends " + class_data.inherits;
|
||||
@ -300,10 +300,10 @@ Error GDScriptWorkspace::initialize() {
|
||||
|
||||
for (int i = 0; i < class_data.constants.size(); i++) {
|
||||
const DocData::ConstantDoc &const_data = class_data.constants[i];
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
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;
|
||||
if (const_data.enumeration.length()) {
|
||||
symbol.detail += ": " + const_data.enumeration;
|
||||
@ -315,10 +315,10 @@ Error GDScriptWorkspace::initialize() {
|
||||
|
||||
for (int i = 0; i < class_data.properties.size(); i++) {
|
||||
const DocData::PropertyDoc &data = class_data.properties[i];
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = data.name;
|
||||
symbol.native_class = class_name;
|
||||
symbol.kind = lsp::SymbolKind::Property;
|
||||
symbol.kind = LSP::SymbolKind::Property;
|
||||
symbol.detail = "var " + class_name + "." + data.name;
|
||||
if (data.enumeration.length()) {
|
||||
symbol.detail += ": " + data.enumeration;
|
||||
@ -331,10 +331,10 @@ Error GDScriptWorkspace::initialize() {
|
||||
|
||||
for (int i = 0; i < class_data.theme_properties.size(); i++) {
|
||||
const DocData::ThemeItemDoc &data = class_data.theme_properties[i];
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
symbol.name = data.name;
|
||||
symbol.native_class = class_name;
|
||||
symbol.kind = lsp::SymbolKind::Property;
|
||||
symbol.kind = LSP::SymbolKind::Property;
|
||||
symbol.detail = "<Theme> var " + class_name + "." + data.name + ": " + data.type;
|
||||
symbol.documentation = data.description;
|
||||
class_symbol.children.push_back(symbol);
|
||||
@ -350,19 +350,19 @@ Error GDScriptWorkspace::initialize() {
|
||||
for (int i = 0; i < methods_signals.size(); i++) {
|
||||
const DocData::MethodDoc &data = methods_signals[i];
|
||||
|
||||
lsp::DocumentSymbol symbol;
|
||||
LSP::DocumentSymbol symbol;
|
||||
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 = "";
|
||||
bool arg_default_value_started = false;
|
||||
for (int j = 0; j < data.arguments.size(); j++) {
|
||||
const DocData::ArgumentDoc &arg = data.arguments[j];
|
||||
|
||||
lsp::DocumentSymbol symbol_arg;
|
||||
LSP::DocumentSymbol symbol_arg;
|
||||
symbol_arg.name = arg.name;
|
||||
symbol_arg.kind = lsp::SymbolKind::Variable;
|
||||
symbol_arg.kind = LSP::SymbolKind::Variable;
|
||||
symbol_arg.detail = arg.type;
|
||||
|
||||
if (!arg_default_value_started && !arg.default_value.is_empty()) {
|
||||
@ -398,11 +398,11 @@ Error GDScriptWorkspace::initialize() {
|
||||
reload_all_workspace_scripts();
|
||||
|
||||
if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
for (const KeyValue<StringName, lsp::DocumentSymbol> &E : native_symbols) {
|
||||
for (const KeyValue<StringName, LSP::DocumentSymbol> &E : native_symbols) {
|
||||
ClassMembers members;
|
||||
const lsp::DocumentSymbol &class_symbol = E.value;
|
||||
const LSP::DocumentSymbol &class_symbol = E.value;
|
||||
for (int i = 0; i < class_symbol.children.size(); i++) {
|
||||
const lsp::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
const LSP::DocumentSymbol &symbol = class_symbol.children[i];
|
||||
members.insert(symbol.name, &symbol);
|
||||
}
|
||||
native_members.insert(E.key, members);
|
||||
@ -443,7 +443,7 @@ Error GDScriptWorkspace::parse_script(const String &p_path, const String &p_cont
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool is_valid_rename_target(const lsp::DocumentSymbol *p_symbol) {
|
||||
static bool is_valid_rename_target(const LSP::DocumentSymbol *p_symbol) {
|
||||
// Must be valid symbol.
|
||||
if (!p_symbol) {
|
||||
return false;
|
||||
@ -462,14 +462,14 @@ static bool is_valid_rename_target(const lsp::DocumentSymbol *p_symbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary GDScriptWorkspace::rename(const lsp::TextDocumentPositionParams &p_doc_pos, const String &new_name) {
|
||||
lsp::WorkspaceEdit edit;
|
||||
Dictionary GDScriptWorkspace::rename(const LSP::TextDocumentPositionParams &p_doc_pos, const String &new_name) {
|
||||
LSP::WorkspaceEdit edit;
|
||||
|
||||
const lsp::DocumentSymbol *reference_symbol = resolve_symbol(p_doc_pos);
|
||||
const LSP::DocumentSymbol *reference_symbol = resolve_symbol(p_doc_pos);
|
||||
if (is_valid_rename_target(reference_symbol)) {
|
||||
Vector<lsp::Location> usages = find_all_usages(*reference_symbol);
|
||||
Vector<LSP::Location> usages = find_all_usages(*reference_symbol);
|
||||
for (int i = 0; i < usages.size(); ++i) {
|
||||
lsp::Location loc = usages[i];
|
||||
LSP::Location loc = usages[i];
|
||||
|
||||
edit.add_change(loc.uri, loc.range.start.line, loc.range.start.character, loc.range.end.character, new_name);
|
||||
}
|
||||
@ -478,8 +478,8 @@ Dictionary GDScriptWorkspace::rename(const lsp::TextDocumentPositionParams &p_do
|
||||
return edit.to_json();
|
||||
}
|
||||
|
||||
bool GDScriptWorkspace::can_rename(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::DocumentSymbol &r_symbol, lsp::Range &r_range) {
|
||||
const lsp::DocumentSymbol *reference_symbol = resolve_symbol(p_doc_pos);
|
||||
bool GDScriptWorkspace::can_rename(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::DocumentSymbol &r_symbol, LSP::Range &r_range) {
|
||||
const LSP::DocumentSymbol *reference_symbol = resolve_symbol(p_doc_pos);
|
||||
if (!is_valid_rename_target(reference_symbol)) {
|
||||
return false;
|
||||
}
|
||||
@ -494,8 +494,8 @@ bool GDScriptWorkspace::can_rename(const lsp::TextDocumentPositionParams &p_doc_
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<lsp::Location> GDScriptWorkspace::find_usages_in_file(const lsp::DocumentSymbol &p_symbol, const String &p_file_path) {
|
||||
Vector<lsp::Location> usages;
|
||||
Vector<LSP::Location> GDScriptWorkspace::find_usages_in_file(const LSP::DocumentSymbol &p_symbol, const String &p_file_path) {
|
||||
Vector<LSP::Location> usages;
|
||||
|
||||
String identifier = p_symbol.name;
|
||||
if (const ExtendGDScriptParser *parser = get_parse_result(p_file_path)) {
|
||||
@ -505,19 +505,19 @@ Vector<lsp::Location> GDScriptWorkspace::find_usages_in_file(const lsp::Document
|
||||
|
||||
int character = line.find(identifier);
|
||||
while (character > -1) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams params;
|
||||
|
||||
lsp::TextDocumentIdentifier text_doc;
|
||||
LSP::TextDocumentIdentifier text_doc;
|
||||
text_doc.uri = get_file_uri(p_file_path);
|
||||
|
||||
params.textDocument = text_doc;
|
||||
params.position.line = i;
|
||||
params.position.character = character;
|
||||
|
||||
const lsp::DocumentSymbol *other_symbol = resolve_symbol(params);
|
||||
const LSP::DocumentSymbol *other_symbol = resolve_symbol(params);
|
||||
|
||||
if (other_symbol == &p_symbol) {
|
||||
lsp::Location loc;
|
||||
LSP::Location loc;
|
||||
loc.uri = text_doc.uri;
|
||||
loc.range.start = params.position;
|
||||
loc.range.end.line = params.position.line;
|
||||
@ -533,7 +533,7 @@ Vector<lsp::Location> GDScriptWorkspace::find_usages_in_file(const lsp::Document
|
||||
return usages;
|
||||
}
|
||||
|
||||
Vector<lsp::Location> GDScriptWorkspace::find_all_usages(const lsp::DocumentSymbol &p_symbol) {
|
||||
Vector<LSP::Location> GDScriptWorkspace::find_all_usages(const LSP::DocumentSymbol &p_symbol) {
|
||||
if (p_symbol.local) {
|
||||
// Only search in current document.
|
||||
return find_usages_in_file(p_symbol, p_symbol.script_path);
|
||||
@ -542,7 +542,7 @@ Vector<lsp::Location> GDScriptWorkspace::find_all_usages(const lsp::DocumentSymb
|
||||
List<String> paths;
|
||||
list_script_files("res://", paths);
|
||||
|
||||
Vector<lsp::Location> usages;
|
||||
Vector<LSP::Location> usages;
|
||||
for (List<String>::Element *PE = paths.front(); PE; PE = PE->next()) {
|
||||
usages.append_array(find_usages_in_file(p_symbol, PE->get()));
|
||||
}
|
||||
@ -576,7 +576,7 @@ void GDScriptWorkspace::publish_diagnostics(const String &p_path) {
|
||||
Array errors;
|
||||
HashMap<String, ExtendGDScriptParser *>::ConstIterator ele = parse_results.find(p_path);
|
||||
if (ele) {
|
||||
const Vector<lsp::Diagnostic> &list = ele->value->get_diagnostics();
|
||||
const Vector<LSP::Diagnostic> &list = ele->value->get_diagnostics();
|
||||
errors.resize(list.size());
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
errors[i] = list[i].to_json();
|
||||
@ -632,7 +632,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
|
||||
return owner_scene_node;
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options) {
|
||||
void GDScriptWorkspace::completion(const LSP::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options) {
|
||||
String path = get_file_path(p_params.textDocument.uri);
|
||||
String call_hint;
|
||||
bool forced = false;
|
||||
@ -670,8 +670,8 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||
}
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_required) {
|
||||
const lsp::DocumentSymbol *symbol = nullptr;
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const LSP::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_required) {
|
||||
const LSP::DocumentSymbol *symbol = nullptr;
|
||||
|
||||
String path = get_file_path(p_doc_pos.textDocument.uri);
|
||||
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
|
||||
@ -681,9 +681,9 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
|
||||
symbol_identifier = identifier_parts[0];
|
||||
}
|
||||
|
||||
lsp::Position pos = p_doc_pos.position;
|
||||
LSP::Position pos = p_doc_pos.position;
|
||||
if (symbol_identifier.is_empty()) {
|
||||
lsp::Range range;
|
||||
LSP::Range range;
|
||||
symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, range);
|
||||
pos.character = range.end.character;
|
||||
}
|
||||
@ -712,7 +712,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
|
||||
|
||||
if (symbol) {
|
||||
switch (symbol->kind) {
|
||||
case lsp::SymbolKind::Function: {
|
||||
case LSP::SymbolKind::Function: {
|
||||
if (symbol->name != symbol_identifier) {
|
||||
symbol = get_parameter_symbol(symbol, symbol_identifier);
|
||||
}
|
||||
@ -740,16 +740,16 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list) {
|
||||
void GDScriptWorkspace::resolve_related_symbols(const LSP::TextDocumentPositionParams &p_doc_pos, List<const LSP::DocumentSymbol *> &r_list) {
|
||||
String path = get_file_path(p_doc_pos.textDocument.uri);
|
||||
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
|
||||
String symbol_identifier;
|
||||
lsp::Range range;
|
||||
LSP::Range range;
|
||||
symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, range);
|
||||
|
||||
for (const KeyValue<StringName, ClassMembers> &E : native_members) {
|
||||
const ClassMembers &members = native_members.get(E.key);
|
||||
if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
|
||||
if (const LSP::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
|
||||
r_list.push_back(*symbol);
|
||||
}
|
||||
}
|
||||
@ -757,13 +757,13 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
|
||||
for (const KeyValue<String, ExtendGDScriptParser *> &E : scripts) {
|
||||
const ExtendGDScriptParser *scr = E.value;
|
||||
const ClassMembers &members = scr->get_members();
|
||||
if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
|
||||
if (const LSP::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
|
||||
r_list.push_back(*symbol);
|
||||
}
|
||||
|
||||
for (const KeyValue<String, ClassMembers> &F : scr->get_inner_classes()) {
|
||||
const ClassMembers *inner_class = &F.value;
|
||||
if (const lsp::DocumentSymbol *const *symbol = inner_class->getptr(symbol_identifier)) {
|
||||
if (const LSP::DocumentSymbol *const *symbol = inner_class->getptr(symbol_identifier)) {
|
||||
r_list.push_back(*symbol);
|
||||
}
|
||||
}
|
||||
@ -771,9 +771,9 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
|
||||
}
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params) {
|
||||
if (HashMap<StringName, lsp::DocumentSymbol>::Iterator E = native_symbols.find(p_params.native_class)) {
|
||||
const lsp::DocumentSymbol &symbol = E->value;
|
||||
const LSP::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const LSP::NativeSymbolInspectParams &p_params) {
|
||||
if (HashMap<StringName, LSP::DocumentSymbol>::Iterator E = native_symbols.find(p_params.native_class)) {
|
||||
const LSP::DocumentSymbol &symbol = E->value;
|
||||
if (p_params.symbol_name.is_empty() || p_params.symbol_name == symbol.name) {
|
||||
return &symbol;
|
||||
}
|
||||
@ -788,10 +788,10 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) {
|
||||
void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<LSP::DocumentLink> &r_list) {
|
||||
if (const ExtendGDScriptParser *parser = get_parse_successed_script(get_file_path(p_uri))) {
|
||||
const List<lsp::DocumentLink> &links = parser->get_document_links();
|
||||
for (const lsp::DocumentLink &E : links) {
|
||||
const List<LSP::DocumentLink> &links = parser->get_document_links();
|
||||
for (const LSP::DocumentLink &E : links) {
|
||||
r_list.push_back(E);
|
||||
}
|
||||
}
|
||||
@ -805,29 +805,29 @@ Dictionary GDScriptWorkspace::generate_script_api(const String &p_path) {
|
||||
return api;
|
||||
}
|
||||
|
||||
Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature) {
|
||||
Error GDScriptWorkspace::resolve_signature(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::SignatureHelp &r_signature) {
|
||||
if (const ExtendGDScriptParser *parser = get_parse_result(get_file_path(p_doc_pos.textDocument.uri))) {
|
||||
lsp::TextDocumentPositionParams text_pos;
|
||||
LSP::TextDocumentPositionParams text_pos;
|
||||
text_pos.textDocument = p_doc_pos.textDocument;
|
||||
|
||||
if (parser->get_left_function_call(p_doc_pos.position, text_pos.position, r_signature.activeParameter) == OK) {
|
||||
List<const lsp::DocumentSymbol *> symbols;
|
||||
List<const LSP::DocumentSymbol *> symbols;
|
||||
|
||||
if (const lsp::DocumentSymbol *symbol = resolve_symbol(text_pos)) {
|
||||
if (const LSP::DocumentSymbol *symbol = resolve_symbol(text_pos)) {
|
||||
symbols.push_back(symbol);
|
||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(text_pos, symbols);
|
||||
}
|
||||
|
||||
for (const lsp::DocumentSymbol *const &symbol : symbols) {
|
||||
if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) {
|
||||
lsp::SignatureInformation signature_info;
|
||||
for (const LSP::DocumentSymbol *const &symbol : symbols) {
|
||||
if (symbol->kind == LSP::SymbolKind::Method || symbol->kind == LSP::SymbolKind::Function) {
|
||||
LSP::SignatureInformation signature_info;
|
||||
signature_info.label = symbol->detail;
|
||||
signature_info.documentation = symbol->render();
|
||||
|
||||
for (int i = 0; i < symbol->children.size(); i++) {
|
||||
const lsp::DocumentSymbol &arg = symbol->children[i];
|
||||
lsp::ParameterInformation arg_info;
|
||||
const LSP::DocumentSymbol &arg = symbol->children[i];
|
||||
LSP::ParameterInformation arg_info;
|
||||
arg_info.label = arg.name;
|
||||
signature_info.parameters.push_back(arg_info);
|
||||
}
|
||||
|
||||
@ -48,12 +48,12 @@ protected:
|
||||
static void _bind_methods();
|
||||
void remove_cache_parser(const String &p_path);
|
||||
bool initialized = false;
|
||||
HashMap<StringName, lsp::DocumentSymbol> native_symbols;
|
||||
HashMap<StringName, LSP::DocumentSymbol> native_symbols;
|
||||
|
||||
const lsp::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;
|
||||
const lsp::DocumentSymbol *get_script_symbol(const String &p_path) const;
|
||||
const lsp::DocumentSymbol *get_parameter_symbol(const lsp::DocumentSymbol *p_parent, const String &symbol_identifier);
|
||||
const lsp::DocumentSymbol *get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const lsp::Position p_position);
|
||||
const LSP::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;
|
||||
const LSP::DocumentSymbol *get_script_symbol(const String &p_path) const;
|
||||
const LSP::DocumentSymbol *get_parameter_symbol(const LSP::DocumentSymbol *p_parent, const String &symbol_identifier);
|
||||
const LSP::DocumentSymbol *get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const LSP::Position p_position);
|
||||
|
||||
void reload_all_workspace_scripts();
|
||||
|
||||
@ -82,19 +82,19 @@ public:
|
||||
String get_file_uri(const String &p_path) const;
|
||||
|
||||
void publish_diagnostics(const String &p_path);
|
||||
void completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options);
|
||||
void completion(const LSP::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options);
|
||||
|
||||
const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);
|
||||
void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list);
|
||||
const lsp::DocumentSymbol *resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params);
|
||||
void resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list);
|
||||
const LSP::DocumentSymbol *resolve_symbol(const LSP::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);
|
||||
void resolve_related_symbols(const LSP::TextDocumentPositionParams &p_doc_pos, List<const LSP::DocumentSymbol *> &r_list);
|
||||
const LSP::DocumentSymbol *resolve_native_symbol(const LSP::NativeSymbolInspectParams &p_params);
|
||||
void resolve_document_links(const String &p_uri, List<LSP::DocumentLink> &r_list);
|
||||
Dictionary generate_script_api(const String &p_path);
|
||||
Error resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature);
|
||||
Error resolve_signature(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::SignatureHelp &r_signature);
|
||||
void did_delete_files(const Dictionary &p_params);
|
||||
Dictionary rename(const lsp::TextDocumentPositionParams &p_doc_pos, const String &new_name);
|
||||
bool can_rename(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::DocumentSymbol &r_symbol, lsp::Range &r_range);
|
||||
Vector<lsp::Location> find_usages_in_file(const lsp::DocumentSymbol &p_symbol, const String &p_file_path);
|
||||
Vector<lsp::Location> find_all_usages(const lsp::DocumentSymbol &p_symbol);
|
||||
Dictionary rename(const LSP::TextDocumentPositionParams &p_doc_pos, const String &new_name);
|
||||
bool can_rename(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::DocumentSymbol &r_symbol, LSP::Range &r_range);
|
||||
Vector<LSP::Location> find_usages_in_file(const LSP::DocumentSymbol &p_symbol, const String &p_file_path);
|
||||
Vector<LSP::Location> find_all_usages(const LSP::DocumentSymbol &p_symbol);
|
||||
|
||||
GDScriptWorkspace();
|
||||
~GDScriptWorkspace();
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/templates/list.h"
|
||||
|
||||
namespace lsp {
|
||||
namespace LSP {
|
||||
|
||||
typedef String DocumentUri;
|
||||
|
||||
@ -383,7 +383,7 @@ struct Command {
|
||||
};
|
||||
|
||||
// Use namespace instead of enumeration to follow the LSP specifications.
|
||||
// `lsp::EnumName::EnumValue` is OK but `lsp::EnumValue` is not.
|
||||
// `LSP::EnumName::EnumValue` is OK but `LSP::EnumValue` is not.
|
||||
|
||||
namespace TextDocumentSyncKind {
|
||||
/**
|
||||
@ -860,7 +860,7 @@ struct MarkupContent {
|
||||
};
|
||||
|
||||
// Use namespace instead of enumeration to follow the LSP specifications
|
||||
// `lsp::EnumName::EnumValue` is OK but `lsp::EnumValue` is not.
|
||||
// `LSP::EnumName::EnumValue` is OK but `LSP::EnumValue` is not.
|
||||
// And here C++ compilers are unhappy with our enumeration name like `Color`, `File`, `RefCounted` etc.
|
||||
/**
|
||||
* The kind of a completion entry.
|
||||
@ -1117,7 +1117,7 @@ struct CompletionList {
|
||||
};
|
||||
|
||||
// Use namespace instead of enumeration to follow the LSP specifications
|
||||
// `lsp::EnumName::EnumValue` is OK but `lsp::EnumValue` is not
|
||||
// `LSP::EnumName::EnumValue` is OK but `LSP::EnumValue` is not
|
||||
// And here C++ compilers are unhappy with our enumeration name like `String`, `Array`, `Object` etc
|
||||
/**
|
||||
* A symbol kind.
|
||||
@ -1258,7 +1258,7 @@ struct DocumentSymbol {
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ CompletionItem make_completion_item(bool resolved = false) const {
|
||||
lsp::CompletionItem item;
|
||||
LSP::CompletionItem item;
|
||||
item.label = name;
|
||||
|
||||
if (resolved) {
|
||||
@ -1266,33 +1266,33 @@ struct DocumentSymbol {
|
||||
}
|
||||
|
||||
switch (kind) {
|
||||
case lsp::SymbolKind::Enum:
|
||||
item.kind = lsp::CompletionItemKind::Enum;
|
||||
case LSP::SymbolKind::Enum:
|
||||
item.kind = LSP::CompletionItemKind::Enum;
|
||||
break;
|
||||
case lsp::SymbolKind::Class:
|
||||
item.kind = lsp::CompletionItemKind::Class;
|
||||
case LSP::SymbolKind::Class:
|
||||
item.kind = LSP::CompletionItemKind::Class;
|
||||
break;
|
||||
case lsp::SymbolKind::Property:
|
||||
item.kind = lsp::CompletionItemKind::Property;
|
||||
case LSP::SymbolKind::Property:
|
||||
item.kind = LSP::CompletionItemKind::Property;
|
||||
break;
|
||||
case lsp::SymbolKind::Method:
|
||||
case lsp::SymbolKind::Function:
|
||||
item.kind = lsp::CompletionItemKind::Method;
|
||||
case LSP::SymbolKind::Method:
|
||||
case LSP::SymbolKind::Function:
|
||||
item.kind = LSP::CompletionItemKind::Method;
|
||||
break;
|
||||
case lsp::SymbolKind::Event:
|
||||
item.kind = lsp::CompletionItemKind::Event;
|
||||
case LSP::SymbolKind::Event:
|
||||
item.kind = LSP::CompletionItemKind::Event;
|
||||
break;
|
||||
case lsp::SymbolKind::Constant:
|
||||
item.kind = lsp::CompletionItemKind::Constant;
|
||||
case LSP::SymbolKind::Constant:
|
||||
item.kind = LSP::CompletionItemKind::Constant;
|
||||
break;
|
||||
case lsp::SymbolKind::Variable:
|
||||
item.kind = lsp::CompletionItemKind::Variable;
|
||||
case LSP::SymbolKind::Variable:
|
||||
item.kind = LSP::CompletionItemKind::Variable;
|
||||
break;
|
||||
case lsp::SymbolKind::File:
|
||||
item.kind = lsp::CompletionItemKind::File;
|
||||
case LSP::SymbolKind::File:
|
||||
item.kind = LSP::CompletionItemKind::File;
|
||||
break;
|
||||
default:
|
||||
item.kind = lsp::CompletionItemKind::Text;
|
||||
item.kind = LSP::CompletionItemKind::Text;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1952,4 +1952,4 @@ static String marked_documentation(const String &p_bbcode) {
|
||||
}
|
||||
return markdown;
|
||||
}
|
||||
} // namespace lsp
|
||||
} // namespace LSP
|
||||
|
||||
@ -55,15 +55,15 @@
|
||||
#include "thirdparty/doctest/doctest.h"
|
||||
|
||||
template <>
|
||||
struct doctest::StringMaker<lsp::Position> {
|
||||
static doctest::String convert(const lsp::Position &p_val) {
|
||||
struct doctest::StringMaker<LSP::Position> {
|
||||
static doctest::String convert(const LSP::Position &p_val) {
|
||||
return p_val.to_string().utf8().get_data();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct doctest::StringMaker<lsp::Range> {
|
||||
static doctest::String convert(const lsp::Range &p_val) {
|
||||
struct doctest::StringMaker<LSP::Range> {
|
||||
static doctest::String convert(const LSP::Range &p_val) {
|
||||
return p_val.to_string().utf8().get_data();
|
||||
}
|
||||
};
|
||||
@ -105,32 +105,32 @@ GDScriptLanguageProtocol *initialize(const String &p_root) {
|
||||
return proto;
|
||||
}
|
||||
|
||||
lsp::Position pos(const int p_line, const int p_character) {
|
||||
lsp::Position p;
|
||||
LSP::Position pos(const int p_line, const int p_character) {
|
||||
LSP::Position p;
|
||||
p.line = p_line;
|
||||
p.character = p_character;
|
||||
return p;
|
||||
}
|
||||
|
||||
lsp::Range range(const lsp::Position p_start, const lsp::Position p_end) {
|
||||
lsp::Range r;
|
||||
LSP::Range range(const LSP::Position p_start, const LSP::Position p_end) {
|
||||
LSP::Range r;
|
||||
r.start = p_start;
|
||||
r.end = p_end;
|
||||
return r;
|
||||
}
|
||||
|
||||
lsp::TextDocumentPositionParams pos_in(const lsp::DocumentUri &p_uri, const lsp::Position p_pos) {
|
||||
lsp::TextDocumentPositionParams params;
|
||||
LSP::TextDocumentPositionParams pos_in(const LSP::DocumentUri &p_uri, const LSP::Position p_pos) {
|
||||
LSP::TextDocumentPositionParams params;
|
||||
params.textDocument.uri = p_uri;
|
||||
params.position = p_pos;
|
||||
return params;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *test_resolve_symbol_at(const String &p_uri, const lsp::Position p_pos, const String &p_expected_uri, const String &p_expected_name, const lsp::Range &p_expected_range) {
|
||||
const LSP::DocumentSymbol *test_resolve_symbol_at(const String &p_uri, const LSP::Position p_pos, const String &p_expected_uri, const String &p_expected_name, const LSP::Range &p_expected_range) {
|
||||
Ref<GDScriptWorkspace> workspace = GDScriptLanguageProtocol::get_singleton()->get_workspace();
|
||||
|
||||
lsp::TextDocumentPositionParams params = pos_in(p_uri, p_pos);
|
||||
const lsp::DocumentSymbol *symbol = workspace->resolve_symbol(params);
|
||||
LSP::TextDocumentPositionParams params = pos_in(p_uri, p_pos);
|
||||
const LSP::DocumentSymbol *symbol = workspace->resolve_symbol(params);
|
||||
CHECK(symbol);
|
||||
|
||||
if (symbol) {
|
||||
@ -143,7 +143,7 @@ const lsp::DocumentSymbol *test_resolve_symbol_at(const String &p_uri, const lsp
|
||||
}
|
||||
|
||||
struct InlineTestData {
|
||||
lsp::Range range;
|
||||
LSP::Range range;
|
||||
String text;
|
||||
String name;
|
||||
String ref;
|
||||
@ -260,7 +260,7 @@ void test_resolve_symbol(const String &p_uri, const InlineTestData &p_test_data,
|
||||
REQUIRE_MESSAGE(target, vformat("No target for ref '%s'", p_test_data.ref));
|
||||
|
||||
Ref<GDScriptWorkspace> workspace = GDScriptLanguageProtocol::get_singleton()->get_workspace();
|
||||
lsp::Position pos = p_test_data.range.start;
|
||||
LSP::Position pos = p_test_data.range.start;
|
||||
|
||||
SUBCASE("start of identifier") {
|
||||
pos.character = p_test_data.range.start.character;
|
||||
@ -311,17 +311,17 @@ void assert_no_errors_in(const String &p_path) {
|
||||
REQUIRE_MESSAGE(err == OK, vformat("Errors while analyzing '%s'", p_path));
|
||||
}
|
||||
|
||||
inline lsp::Position lsp_pos(int line, int character) {
|
||||
lsp::Position p;
|
||||
inline LSP::Position lsp_pos(int line, int character) {
|
||||
LSP::Position p;
|
||||
p.line = line;
|
||||
p.character = character;
|
||||
return p;
|
||||
}
|
||||
|
||||
void test_position_roundtrip(lsp::Position p_lsp, GodotPosition p_gd, const PackedStringArray &p_lines) {
|
||||
void test_position_roundtrip(LSP::Position p_lsp, GodotPosition p_gd, const PackedStringArray &p_lines) {
|
||||
GodotPosition actual_gd = GodotPosition::from_lsp(p_lsp, p_lines);
|
||||
CHECK_EQ(p_gd, actual_gd);
|
||||
lsp::Position actual_lsp = p_gd.to_lsp(p_lines);
|
||||
LSP::Position actual_lsp = p_gd.to_lsp(p_lines);
|
||||
CHECK_EQ(p_lsp, actual_lsp);
|
||||
}
|
||||
|
||||
@ -346,25 +346,25 @@ func f():
|
||||
PackedStringArray lines = code.split("\n");
|
||||
|
||||
SUBCASE("line after end") {
|
||||
lsp::Position lsp = lsp_pos(7, 0);
|
||||
LSP::Position lsp = lsp_pos(7, 0);
|
||||
GodotPosition gd(8, 1);
|
||||
test_position_roundtrip(lsp, gd, lines);
|
||||
}
|
||||
SUBCASE("first char in first line") {
|
||||
lsp::Position lsp = lsp_pos(0, 0);
|
||||
LSP::Position lsp = lsp_pos(0, 0);
|
||||
GodotPosition gd(1, 1);
|
||||
test_position_roundtrip(lsp, gd, lines);
|
||||
}
|
||||
|
||||
SUBCASE("with tabs") {
|
||||
// On `v` in `value` in `var value := ...`.
|
||||
lsp::Position lsp = lsp_pos(5, 6);
|
||||
LSP::Position lsp = lsp_pos(5, 6);
|
||||
GodotPosition gd(6, 13);
|
||||
test_position_roundtrip(lsp, gd, lines);
|
||||
}
|
||||
|
||||
SUBCASE("doesn't fail with column outside of character length") {
|
||||
lsp::Position lsp = lsp_pos(2, 100);
|
||||
LSP::Position lsp = lsp_pos(2, 100);
|
||||
GodotPosition::from_lsp(lsp, lines);
|
||||
|
||||
GodotPosition gd(3, 100);
|
||||
@ -372,7 +372,7 @@ func f():
|
||||
}
|
||||
|
||||
SUBCASE("doesn't fail with line outside of line length") {
|
||||
lsp::Position lsp = lsp_pos(200, 100);
|
||||
LSP::Position lsp = lsp_pos(200, 100);
|
||||
GodotPosition::from_lsp(lsp, lines);
|
||||
|
||||
GodotPosition gd(300, 100);
|
||||
@ -381,26 +381,26 @@ func f():
|
||||
|
||||
SUBCASE("special case: zero column for root class") {
|
||||
GodotPosition gd(1, 0);
|
||||
lsp::Position expected = lsp_pos(0, 0);
|
||||
lsp::Position actual = gd.to_lsp(lines);
|
||||
LSP::Position expected = lsp_pos(0, 0);
|
||||
LSP::Position actual = gd.to_lsp(lines);
|
||||
CHECK_EQ(actual, expected);
|
||||
}
|
||||
SUBCASE("special case: zero line and column for root class") {
|
||||
GodotPosition gd(0, 0);
|
||||
lsp::Position expected = lsp_pos(0, 0);
|
||||
lsp::Position actual = gd.to_lsp(lines);
|
||||
LSP::Position expected = lsp_pos(0, 0);
|
||||
LSP::Position actual = gd.to_lsp(lines);
|
||||
CHECK_EQ(actual, expected);
|
||||
}
|
||||
SUBCASE("special case: negative line for root class") {
|
||||
GodotPosition gd(-1, 0);
|
||||
lsp::Position expected = lsp_pos(0, 0);
|
||||
lsp::Position actual = gd.to_lsp(lines);
|
||||
LSP::Position expected = lsp_pos(0, 0);
|
||||
LSP::Position actual = gd.to_lsp(lines);
|
||||
CHECK_EQ(actual, expected);
|
||||
}
|
||||
SUBCASE("special case: lines.length() + 1 for root class") {
|
||||
GodotPosition gd(lines.size() + 1, 0);
|
||||
lsp::Position expected = lsp_pos(lines.size(), 0);
|
||||
lsp::Position actual = gd.to_lsp(lines);
|
||||
LSP::Position expected = lsp_pos(lines.size(), 0);
|
||||
LSP::Position actual = gd.to_lsp(lines);
|
||||
CHECK_EQ(actual, expected);
|
||||
}
|
||||
}
|
||||
@ -502,7 +502,7 @@ func f():
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_local_script(path);
|
||||
ExtendGDScriptParser *parser = GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_results[path];
|
||||
REQUIRE(parser);
|
||||
lsp::DocumentSymbol cls = parser->get_symbols();
|
||||
LSP::DocumentSymbol cls = parser->get_symbols();
|
||||
|
||||
REQUIRE(((cls.range.start.line == cls.selectionRange.start.line && cls.range.start.character <= cls.selectionRange.start.character) || (cls.range.start.line < cls.selectionRange.start.line)));
|
||||
REQUIRE(((cls.range.end.line == cls.selectionRange.end.line && cls.range.end.character >= cls.selectionRange.end.character) || (cls.range.end.line > cls.selectionRange.end.line)));
|
||||
|
||||
@ -613,7 +613,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
|
||||
return false; // Already up to date
|
||||
}
|
||||
} else {
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
|
||||
assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir()
|
||||
.path_join(assembly_name + ".dll");
|
||||
|
||||
@ -1740,8 +1740,8 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
da->make_dir("Generated");
|
||||
da->make_dir("Generated/GodotObjects");
|
||||
|
||||
String base_gen_dir = path::join(p_proj_dir, "Generated");
|
||||
String godot_objects_gen_dir = path::join(base_gen_dir, "GodotObjects");
|
||||
String base_gen_dir = Path::join(p_proj_dir, "Generated");
|
||||
String godot_objects_gen_dir = Path::join(base_gen_dir, "GodotObjects");
|
||||
|
||||
Vector<String> compile_items;
|
||||
|
||||
@ -1749,7 +1749,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
{
|
||||
StringBuilder constants_source;
|
||||
_generate_global_constants(constants_source);
|
||||
String output_file = path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
|
||||
String output_file = Path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
|
||||
Error save_err = _save_file(output_file, constants_source);
|
||||
if (save_err != OK) {
|
||||
return save_err;
|
||||
@ -1762,7 +1762,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
{
|
||||
StringBuilder extensions_source;
|
||||
_generate_array_extensions(extensions_source);
|
||||
String output_file = path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_extensions.cs");
|
||||
String output_file = Path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_extensions.cs");
|
||||
Error save_err = _save_file(output_file, extensions_source);
|
||||
if (save_err != OK) {
|
||||
return save_err;
|
||||
@ -1778,7 +1778,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
|
||||
String output_file = Path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
|
||||
Error err = _generate_cs_type(itype, output_file);
|
||||
|
||||
if (err == ERR_SKIP) {
|
||||
@ -1845,7 +1845,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
|
||||
cs_built_in_ctors_content.append(CLOSE_BLOCK);
|
||||
|
||||
String constructors_file = path::join(base_gen_dir, BINDINGS_CLASS_CONSTRUCTOR ".cs");
|
||||
String constructors_file = Path::join(base_gen_dir, BINDINGS_CLASS_CONSTRUCTOR ".cs");
|
||||
Error err = _save_file(constructors_file, cs_built_in_ctors_content);
|
||||
|
||||
if (err != OK) {
|
||||
@ -1888,7 +1888,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
|
||||
cs_icalls_content.append(CLOSE_BLOCK);
|
||||
|
||||
String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS ".cs");
|
||||
String internal_methods_file = Path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS ".cs");
|
||||
|
||||
Error err = _save_file(internal_methods_file, cs_icalls_content);
|
||||
if (err != OK) {
|
||||
@ -1904,14 +1904,14 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
||||
" <ItemGroup>\n");
|
||||
|
||||
for (int i = 0; i < compile_items.size(); i++) {
|
||||
String include = path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
|
||||
String include = Path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
|
||||
includes_props_content.append(" <Compile Include=\"" + include + "\" />\n");
|
||||
}
|
||||
|
||||
includes_props_content.append(" </ItemGroup>\n"
|
||||
"</Project>\n");
|
||||
|
||||
String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
|
||||
String includes_props_file = Path::join(base_gen_dir, "GeneratedIncludes.props");
|
||||
|
||||
err = _save_file(includes_props_file, includes_props_content);
|
||||
if (err != OK) {
|
||||
@ -1936,8 +1936,8 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
da->make_dir("Generated");
|
||||
da->make_dir("Generated/GodotObjects");
|
||||
|
||||
String base_gen_dir = path::join(p_proj_dir, "Generated");
|
||||
String godot_objects_gen_dir = path::join(base_gen_dir, "GodotObjects");
|
||||
String base_gen_dir = Path::join(p_proj_dir, "Generated");
|
||||
String godot_objects_gen_dir = Path::join(base_gen_dir, "GodotObjects");
|
||||
|
||||
Vector<String> compile_items;
|
||||
|
||||
@ -1948,7 +1948,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
|
||||
String output_file = Path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
|
||||
Error err = _generate_cs_type(itype, output_file);
|
||||
|
||||
if (err == ERR_SKIP) {
|
||||
@ -2003,7 +2003,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
|
||||
cs_built_in_ctors_content.append(CLOSE_BLOCK);
|
||||
|
||||
String constructors_file = path::join(base_gen_dir, BINDINGS_CLASS_CONSTRUCTOR_EDITOR ".cs");
|
||||
String constructors_file = Path::join(base_gen_dir, BINDINGS_CLASS_CONSTRUCTOR_EDITOR ".cs");
|
||||
Error err = _save_file(constructors_file, cs_built_in_ctors_content);
|
||||
|
||||
if (err != OK) {
|
||||
@ -2048,7 +2048,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
|
||||
cs_icalls_content.append(CLOSE_BLOCK);
|
||||
|
||||
String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs");
|
||||
String internal_methods_file = Path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs");
|
||||
|
||||
Error err = _save_file(internal_methods_file, cs_icalls_content);
|
||||
if (err != OK) {
|
||||
@ -2064,14 +2064,14 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
" <ItemGroup>\n");
|
||||
|
||||
for (int i = 0; i < compile_items.size(); i++) {
|
||||
String include = path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
|
||||
String include = Path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
|
||||
includes_props_content.append(" <Compile Include=\"" + include + "\" />\n");
|
||||
}
|
||||
|
||||
includes_props_content.append(" </ItemGroup>\n"
|
||||
"</Project>\n");
|
||||
|
||||
String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
|
||||
String includes_props_file = Path::join(base_gen_dir, "GeneratedIncludes.props");
|
||||
|
||||
err = _save_file(includes_props_file, includes_props_content);
|
||||
if (err != OK) {
|
||||
@ -2084,7 +2084,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
||||
Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
|
||||
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
|
||||
|
||||
String output_dir = path::abspath(path::realpath(p_output_dir));
|
||||
String output_dir = Path::abspath(Path::realpath(p_output_dir));
|
||||
|
||||
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
ERR_FAIL_COND_V(da.is_null(), ERR_CANT_CREATE);
|
||||
|
||||
@ -76,7 +76,7 @@ void godot_icall_GodotSharpDirs_DataEditorToolsDir(godot_string *r_dest) {
|
||||
}
|
||||
|
||||
void godot_icall_GodotSharpDirs_CSharpProjectName(godot_string *r_dest) {
|
||||
memnew_placement(r_dest, String(path::get_csharp_project_name()));
|
||||
memnew_placement(r_dest, String(Path::get_csharp_project_name()));
|
||||
}
|
||||
|
||||
void godot_icall_EditorProgress_Create(const godot_string *p_task, const godot_string *p_label, int32_t p_amount, bool p_can_cancel) {
|
||||
@ -144,7 +144,7 @@ bool godot_icall_Internal_IsAssembliesReloadingNeeded() {
|
||||
|
||||
void godot_icall_Internal_ReloadAssemblies(bool p_soft_reload) {
|
||||
#ifdef GD_MONO_HOT_RELOAD
|
||||
callable_mp(mono_bind::GodotSharp::get_singleton(), &mono_bind::GodotSharp::reload_assemblies).call_deferred(p_soft_reload);
|
||||
callable_mp(MonoBind::GodotSharp::get_singleton(), &MonoBind::GodotSharp::reload_assemblies).call_deferred(p_soft_reload);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -119,8 +119,8 @@ bool get_latest_fxr(const String &fxr_root, String &r_fxr_path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String fxr_with_ver = path::join(fxr_root, latest_ver_str);
|
||||
String hostfxr_file_path = path::join(fxr_with_ver, get_hostfxr_file_name());
|
||||
String fxr_with_ver = Path::join(fxr_root, latest_ver_str);
|
||||
String hostfxr_file_path = Path::join(fxr_with_ver, get_hostfxr_file_name());
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!FileAccess::exists(hostfxr_file_path), false, "Missing hostfxr library in directory: " + fxr_with_ver);
|
||||
|
||||
@ -188,22 +188,22 @@ bool get_default_installation_dir(String &r_dotnet_root) {
|
||||
|
||||
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
|
||||
// When emulating x64 on arm
|
||||
String dotnet_root_emulated = path::join(program_files_dir, "dotnet", "x64");
|
||||
if (FileAccess::exists(path::join(dotnet_root_emulated, "dotnet.exe"))) {
|
||||
String dotnet_root_emulated = Path::join(program_files_dir, "dotnet", "x64");
|
||||
if (FileAccess::exists(Path::join(dotnet_root_emulated, "dotnet.exe"))) {
|
||||
r_dotnet_root = dotnet_root_emulated;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
r_dotnet_root = path::join(program_files_dir, "dotnet");
|
||||
r_dotnet_root = Path::join(program_files_dir, "dotnet");
|
||||
return true;
|
||||
#elif defined(MACOS_ENABLED)
|
||||
r_dotnet_root = "/usr/local/share/dotnet";
|
||||
|
||||
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
|
||||
// When emulating x64 on arm
|
||||
String dotnet_root_emulated = path::join(r_dotnet_root, "x64");
|
||||
if (FileAccess::exists(path::join(dotnet_root_emulated, "dotnet"))) {
|
||||
String dotnet_root_emulated = Path::join(r_dotnet_root, "x64");
|
||||
if (FileAccess::exists(Path::join(dotnet_root_emulated, "dotnet"))) {
|
||||
r_dotnet_root = dotnet_root_emulated;
|
||||
return true;
|
||||
}
|
||||
@ -266,7 +266,7 @@ bool get_dotnet_self_registered_dir(String &r_dotnet_root) {
|
||||
RegCloseKey(hkey);
|
||||
return true;
|
||||
#else
|
||||
String install_location_file = path::join("/etc/dotnet", "install_location_" + get_dotnet_arch().to_lower());
|
||||
String install_location_file = Path::join("/etc/dotnet", "install_location_" + get_dotnet_arch().to_lower());
|
||||
if (get_install_location_from_file(install_location_file, r_dotnet_root)) {
|
||||
return true;
|
||||
}
|
||||
@ -276,7 +276,7 @@ bool get_dotnet_self_registered_dir(String &r_dotnet_root) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String legacy_install_location_file = path::join("/etc/dotnet", "install_location");
|
||||
String legacy_install_location_file = Path::join("/etc/dotnet", "install_location");
|
||||
return get_install_location_from_file(legacy_install_location_file, r_dotnet_root);
|
||||
#endif
|
||||
}
|
||||
@ -285,7 +285,7 @@ bool get_file_path_from_env(const String &p_env_key, String &r_dotnet_root) {
|
||||
String env_value = OS::get_singleton()->get_environment(p_env_key);
|
||||
|
||||
if (!env_value.is_empty()) {
|
||||
env_value = path::realpath(env_value);
|
||||
env_value = Path::realpath(env_value);
|
||||
|
||||
if (DirAccess::exists(env_value)) {
|
||||
r_dotnet_root = env_value;
|
||||
@ -321,7 +321,7 @@ bool get_dotnet_root_from_env(String &r_dotnet_root) {
|
||||
} //namespace
|
||||
|
||||
bool godotsharp::hostfxr_resolver::try_get_path_from_dotnet_root(const String &p_dotnet_root, String &r_fxr_path) {
|
||||
String fxr_dir = path::join(p_dotnet_root, "host", "fxr");
|
||||
String fxr_dir = Path::join(p_dotnet_root, "host", "fxr");
|
||||
if (!DirAccess::exists(fxr_dir)) {
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
ERR_PRINT("The host fxr folder does not exist: " + fxr_dir + ".");
|
||||
|
||||
@ -167,7 +167,7 @@ private:
|
||||
#else // TOOLS_ENABLED
|
||||
String platform = _get_platform_name();
|
||||
String arch = Engine::get_singleton()->get_architecture_name();
|
||||
String appname_safe = path::get_csharp_project_name();
|
||||
String appname_safe = Path::get_csharp_project_name();
|
||||
String packed_path = "res://.godot/mono/publish/" + arch;
|
||||
if (DirAccess::exists(packed_path)) {
|
||||
// The dotnet publish data is packed in the pck/zip.
|
||||
|
||||
@ -101,11 +101,11 @@ String find_hostfxr() {
|
||||
|
||||
// hostfxr_resolver doesn't look for dotnet in `PATH`. If it fails, we try to find the dotnet
|
||||
// executable in `PATH` here and pass its location as `dotnet_root` to `get_hostfxr_path`.
|
||||
String dotnet_exe = path::find_executable("dotnet");
|
||||
String dotnet_exe = Path::find_executable("dotnet");
|
||||
|
||||
if (!dotnet_exe.is_empty()) {
|
||||
// The file found in PATH may be a symlink
|
||||
dotnet_exe = path::abspath(path::realpath(dotnet_exe));
|
||||
dotnet_exe = Path::abspath(Path::realpath(dotnet_exe));
|
||||
|
||||
// TODO:
|
||||
// Sometimes, the symlink may not point to the dotnet executable in the dotnet root.
|
||||
@ -385,7 +385,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime
|
||||
godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime_initialized) {
|
||||
godot_plugins_initialize_fn godot_plugins_initialize = nullptr;
|
||||
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
|
||||
HostFxrCharString assembly_path = str_to_hostfxr(GodotSharpDirs::get_api_assemblies_dir()
|
||||
.path_join(assembly_name + ".dll"));
|
||||
@ -410,7 +410,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime
|
||||
}
|
||||
|
||||
godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle) {
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
|
||||
#if defined(WINDOWS_ENABLED)
|
||||
String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dll");
|
||||
@ -463,7 +463,7 @@ String make_tpa_list() {
|
||||
godot_plugins_initialize_fn initialize_coreclr_and_godot_plugins(bool &r_runtime_initialized) {
|
||||
godot_plugins_initialize_fn godot_plugins_initialize = nullptr;
|
||||
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
|
||||
String tpa_list = make_tpa_list();
|
||||
const char *prop_keys[] = { "TRUSTED_PLATFORM_ASSEMBLIES" };
|
||||
@ -627,7 +627,7 @@ void GDMono::_init_godot_api_hashes() {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool GDMono::_load_project_assembly() {
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
|
||||
String assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir()
|
||||
.path_join(assembly_name + ".dll");
|
||||
@ -658,7 +658,7 @@ void GDMono::reload_failure() {
|
||||
|
||||
ERR_PRINT_ED(".NET: Giving up on assembly reloading. Please restart the editor if unloading was failing.");
|
||||
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
String assembly_path = GodotSharpDirs::get_res_temp_assemblies_dir().path_join(assembly_name + ".dll");
|
||||
assembly_path = ProjectSettings::get_singleton()->globalize_path(assembly_path);
|
||||
project_assembly_path = assembly_path.simplify_path();
|
||||
@ -716,7 +716,7 @@ GDMono::~GDMono() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
namespace mono_bind {
|
||||
namespace MonoBind {
|
||||
|
||||
GodotSharp *GodotSharp::singleton = nullptr;
|
||||
|
||||
@ -739,4 +739,4 @@ GodotSharp::~GodotSharp() {
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
} // namespace mono_bind
|
||||
} // namespace MonoBind
|
||||
|
||||
@ -161,7 +161,7 @@ public:
|
||||
~GDMono();
|
||||
};
|
||||
|
||||
namespace mono_bind {
|
||||
namespace MonoBind {
|
||||
|
||||
class GodotSharp : public Object {
|
||||
GDCLASS(GodotSharp, Object);
|
||||
@ -178,4 +178,4 @@ public:
|
||||
~GodotSharp();
|
||||
};
|
||||
|
||||
} // namespace mono_bind
|
||||
} // namespace MonoBind
|
||||
|
||||
@ -38,7 +38,7 @@ CSharpLanguage *script_language_cs = nullptr;
|
||||
Ref<ResourceFormatLoaderCSharpScript> resource_loader_cs;
|
||||
Ref<ResourceFormatSaverCSharpScript> resource_saver_cs;
|
||||
|
||||
mono_bind::GodotSharp *_godotsharp = nullptr;
|
||||
MonoBind::GodotSharp *_godotsharp = nullptr;
|
||||
|
||||
void initialize_mono_module(ModuleInitializationLevel p_level) {
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
@ -47,7 +47,7 @@ void initialize_mono_module(ModuleInitializationLevel p_level) {
|
||||
|
||||
GDREGISTER_CLASS(CSharpScript);
|
||||
|
||||
_godotsharp = memnew(mono_bind::GodotSharp);
|
||||
_godotsharp = memnew(MonoBind::GodotSharp);
|
||||
|
||||
script_language_cs = memnew(CSharpLanguage);
|
||||
script_language_cs->set_language_index(ScriptServer::get_language_count());
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
#define ENV_PATH_SEP ":"
|
||||
#endif
|
||||
|
||||
namespace path {
|
||||
namespace Path {
|
||||
|
||||
String find_executable(const String &p_name) {
|
||||
#ifdef WINDOWS_ENABLED
|
||||
@ -62,7 +62,7 @@ String find_executable(const String &p_name) {
|
||||
}
|
||||
|
||||
for (int i = 0; i < env_path.size(); i++) {
|
||||
String p = path::join(env_path[i], p_name);
|
||||
String p = Path::join(env_path[i], p_name);
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
for (int j = 0; j < exts.size(); j++) {
|
||||
@ -117,7 +117,7 @@ String abspath(const String &p_path) {
|
||||
if (p_path.is_absolute_path()) {
|
||||
return p_path.simplify_path();
|
||||
} else {
|
||||
return path::join(path::cwd(), p_path).simplify_path();
|
||||
return Path::join(Path::cwd(), p_path).simplify_path();
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,11 +186,11 @@ String join(const String &p_a, const String &p_b) {
|
||||
}
|
||||
|
||||
String join(const String &p_a, const String &p_b, const String &p_c) {
|
||||
return path::join(path::join(p_a, p_b), p_c);
|
||||
return Path::join(Path::join(p_a, p_b), p_c);
|
||||
}
|
||||
|
||||
String join(const String &p_a, const String &p_b, const String &p_c, const String &p_d) {
|
||||
return path::join(path::join(path::join(p_a, p_b), p_c), p_d);
|
||||
return Path::join(Path::join(Path::join(p_a, p_b), p_c), p_d);
|
||||
}
|
||||
|
||||
String relative_to_impl(const String &p_path, const String &p_relative_to) {
|
||||
@ -263,4 +263,4 @@ String get_csharp_project_name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
} // namespace path
|
||||
} // namespace Path
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
namespace path {
|
||||
namespace Path {
|
||||
|
||||
String find_executable(const String &p_name);
|
||||
|
||||
@ -58,4 +58,4 @@ String realpath(const String &p_path);
|
||||
String relative_to(const String &p_path, const String &p_relative_to);
|
||||
|
||||
String get_csharp_project_name();
|
||||
} // namespace path
|
||||
} // namespace Path
|
||||
|
||||
@ -44,7 +44,7 @@ struct NavBaseIteration3D {
|
||||
ObjectID owner_object_id;
|
||||
RID owner_rid;
|
||||
bool owner_use_edge_connections = false;
|
||||
LocalVector<nav_3d::Polygon> navmesh_polygons;
|
||||
LocalVector<Nav3D::Polygon> navmesh_polygons;
|
||||
|
||||
bool get_enabled() const { return enabled; }
|
||||
NavigationUtilities::PathSegmentType get_type() const { return owner_type; }
|
||||
@ -54,5 +54,5 @@ struct NavBaseIteration3D {
|
||||
real_t get_enter_cost() const { return enter_cost; }
|
||||
real_t get_travel_cost() const { return travel_cost; }
|
||||
bool get_use_edge_connections() const { return owner_use_edge_connections; }
|
||||
const LocalVector<nav_3d::Polygon> &get_navmesh_polygons() const { return navmesh_polygons; }
|
||||
const LocalVector<Nav3D::Polygon> &get_navmesh_polygons() const { return navmesh_polygons; }
|
||||
};
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#include "nav_map_iteration_3d.h"
|
||||
#include "nav_region_iteration_3d.h"
|
||||
|
||||
using namespace nav_3d;
|
||||
using namespace Nav3D;
|
||||
|
||||
PointKey NavMapBuilder3D::get_point_key(const Vector3 &p_pos, const Vector3 &p_cell_size) {
|
||||
const int x = static_cast<int>(Math::floor(p_pos.x / p_cell_size.x));
|
||||
|
||||
@ -43,7 +43,7 @@ class NavMapBuilder3D {
|
||||
static void _build_update_map_iteration(NavMapIterationBuild3D &r_build);
|
||||
|
||||
public:
|
||||
static nav_3d::PointKey get_point_key(const Vector3 &p_pos, const Vector3 &p_cell_size);
|
||||
static Nav3D::PointKey get_point_key(const Vector3 &p_pos, const Vector3 &p_cell_size);
|
||||
|
||||
static void build_navmap_iteration(NavMapIterationBuild3D &r_build);
|
||||
};
|
||||
|
||||
@ -47,12 +47,12 @@ struct NavMapIterationBuild3D {
|
||||
bool use_edge_connections = true;
|
||||
real_t edge_connection_margin;
|
||||
real_t link_connection_radius;
|
||||
nav_3d::PerformanceData performance_data;
|
||||
Nav3D::PerformanceData performance_data;
|
||||
int polygon_count = 0;
|
||||
int free_edge_count = 0;
|
||||
|
||||
HashMap<nav_3d::EdgeKey, nav_3d::EdgeConnectionPair, nav_3d::EdgeKey> iter_connection_pairs_map;
|
||||
LocalVector<nav_3d::Edge::Connection> iter_free_edges;
|
||||
HashMap<Nav3D::EdgeKey, Nav3D::EdgeConnectionPair, Nav3D::EdgeKey> iter_connection_pairs_map;
|
||||
LocalVector<Nav3D::Edge::Connection> iter_free_edges;
|
||||
|
||||
NavMapIteration3D *map_iteration = nullptr;
|
||||
|
||||
@ -77,7 +77,7 @@ struct NavMapIteration3D {
|
||||
RWLock rwlock;
|
||||
|
||||
Vector3 map_up;
|
||||
LocalVector<nav_3d::Polygon> link_polygons;
|
||||
LocalVector<Nav3D::Polygon> link_polygons;
|
||||
|
||||
LocalVector<NavRegionIteration3D> region_iterations;
|
||||
LocalVector<NavLinkIteration3D> link_iterations;
|
||||
@ -86,7 +86,7 @@ struct NavMapIteration3D {
|
||||
int link_polygon_count = 0;
|
||||
|
||||
// The edge connections that the map builds on top with the edge connection margin.
|
||||
HashMap<uint32_t, LocalVector<nav_3d::Edge::Connection>> external_region_connections;
|
||||
HashMap<uint32_t, LocalVector<Nav3D::Edge::Connection>> external_region_connections;
|
||||
|
||||
HashMap<NavRegion3D *, uint32_t> region_ptr_to_region_id;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
#include "core/math/geometry_3d.h"
|
||||
#include "servers/navigation/navigation_utilities.h"
|
||||
|
||||
using namespace nav_3d;
|
||||
using namespace Nav3D;
|
||||
|
||||
#define THREE_POINTS_CROSS_PRODUCT(m_a, m_b, m_c) (((m_c) - (m_a)).cross((m_b) - (m_a)))
|
||||
|
||||
|
||||
@ -46,8 +46,8 @@ struct NavMapIteration3D;
|
||||
class NavMeshQueries3D {
|
||||
public:
|
||||
struct PathQuerySlot {
|
||||
LocalVector<nav_3d::NavigationPoly> path_corridor;
|
||||
Heap<nav_3d::NavigationPoly *, nav_3d::NavPolyTravelCostGreaterThan, nav_3d::NavPolyHeapIndexer> traversable_polys;
|
||||
LocalVector<Nav3D::NavigationPoly> path_corridor;
|
||||
Heap<Nav3D::NavigationPoly *, Nav3D::NavPolyTravelCostGreaterThan, Nav3D::NavPolyHeapIndexer> traversable_polys;
|
||||
bool in_use = false;
|
||||
uint32_t slot_index = 0;
|
||||
};
|
||||
@ -78,8 +78,8 @@ public:
|
||||
// Path building.
|
||||
Vector3 begin_position;
|
||||
Vector3 end_position;
|
||||
const nav_3d::Polygon *begin_polygon = nullptr;
|
||||
const nav_3d::Polygon *end_polygon = nullptr;
|
||||
const Nav3D::Polygon *begin_polygon = nullptr;
|
||||
const Nav3D::Polygon *end_polygon = nullptr;
|
||||
uint32_t least_cost_id = 0;
|
||||
|
||||
// Map.
|
||||
@ -115,31 +115,31 @@ public:
|
||||
|
||||
static bool emit_callback(const Callable &p_callback);
|
||||
|
||||
static Vector3 polygons_get_random_point(const LocalVector<nav_3d::Polygon> &p_polygons, uint32_t p_navigation_layers, bool p_uniformly);
|
||||
static Vector3 polygons_get_random_point(const LocalVector<Nav3D::Polygon> &p_polygons, uint32_t p_navigation_layers, bool p_uniformly);
|
||||
|
||||
static Vector3 polygons_get_closest_point_to_segment(const LocalVector<nav_3d::Polygon> &p_polygons, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision);
|
||||
static Vector3 polygons_get_closest_point(const LocalVector<nav_3d::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static Vector3 polygons_get_closest_point_normal(const LocalVector<nav_3d::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static nav_3d::ClosestPointQueryResult polygons_get_closest_point_info(const LocalVector<nav_3d::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static RID polygons_get_closest_point_owner(const LocalVector<nav_3d::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static Vector3 polygons_get_closest_point_to_segment(const LocalVector<Nav3D::Polygon> &p_polygons, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision);
|
||||
static Vector3 polygons_get_closest_point(const LocalVector<Nav3D::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static Vector3 polygons_get_closest_point_normal(const LocalVector<Nav3D::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static Nav3D::ClosestPointQueryResult polygons_get_closest_point_info(const LocalVector<Nav3D::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
static RID polygons_get_closest_point_owner(const LocalVector<Nav3D::Polygon> &p_polygons, const Vector3 &p_point);
|
||||
|
||||
static Vector3 map_iteration_get_closest_point_to_segment(const NavMapIteration3D &p_map_iteration, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision);
|
||||
static Vector3 map_iteration_get_closest_point(const NavMapIteration3D &p_map_iteration, const Vector3 &p_point);
|
||||
static Vector3 map_iteration_get_closest_point_normal(const NavMapIteration3D &p_map_iteration, const Vector3 &p_point);
|
||||
static RID map_iteration_get_closest_point_owner(const NavMapIteration3D &p_map_iteration, const Vector3 &p_point);
|
||||
static nav_3d::ClosestPointQueryResult map_iteration_get_closest_point_info(const NavMapIteration3D &p_map_iteration, const Vector3 &p_point);
|
||||
static Nav3D::ClosestPointQueryResult map_iteration_get_closest_point_info(const NavMapIteration3D &p_map_iteration, const Vector3 &p_point);
|
||||
static Vector3 map_iteration_get_random_point(const NavMapIteration3D &p_map_iteration, uint32_t p_navigation_layers, bool p_uniformly);
|
||||
|
||||
static void map_query_path(NavMap3D *map, const Ref<NavigationPathQueryParameters3D> &p_query_parameters, Ref<NavigationPathQueryResult3D> p_query_result, const Callable &p_callback);
|
||||
|
||||
static void query_task_map_iteration_get_path(NavMeshPathQueryTask3D &p_query_task, const NavMapIteration3D &p_map_iteration);
|
||||
static void _query_task_push_back_point_with_metadata(NavMeshPathQueryTask3D &p_query_task, const Vector3 &p_point, const nav_3d::Polygon *p_point_polygon);
|
||||
static void _query_task_push_back_point_with_metadata(NavMeshPathQueryTask3D &p_query_task, const Vector3 &p_point, const Nav3D::Polygon *p_point_polygon);
|
||||
static void _query_task_find_start_end_positions(NavMeshPathQueryTask3D &p_query_task, const NavMapIteration3D &p_map_iteration);
|
||||
static void _query_task_build_path_corridor(NavMeshPathQueryTask3D &p_query_task);
|
||||
static void _query_task_post_process_corridorfunnel(NavMeshPathQueryTask3D &p_query_task);
|
||||
static void _query_task_post_process_edgecentered(NavMeshPathQueryTask3D &p_query_task);
|
||||
static void _query_task_post_process_nopostprocessing(NavMeshPathQueryTask3D &p_query_task);
|
||||
static void _query_task_clip_path(NavMeshPathQueryTask3D &p_query_task, const nav_3d::NavigationPoly *from_poly, const Vector3 &p_to_point, const nav_3d::NavigationPoly *p_to_poly);
|
||||
static void _query_task_clip_path(NavMeshPathQueryTask3D &p_query_task, const Nav3D::NavigationPoly *from_poly, const Vector3 &p_to_point, const Nav3D::NavigationPoly *p_to_poly);
|
||||
static void _query_task_simplified_path_points(NavMeshPathQueryTask3D &p_query_task);
|
||||
static bool _query_task_is_connection_owner_usable(const NavMeshPathQueryTask3D &p_query_task, const NavBaseIteration3D *p_owner);
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
|
||||
#include <Obstacle2d.h>
|
||||
|
||||
using namespace nav_3d;
|
||||
using namespace Nav3D;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
#define NAVMAP_ITERATION_ZERO_ERROR_MSG() \
|
||||
|
||||
@ -110,7 +110,7 @@ class NavMap3D : public NavRid3D {
|
||||
bool avoidance_use_high_priority_threads = true;
|
||||
|
||||
// Performance Monitor
|
||||
nav_3d::PerformanceData performance_data;
|
||||
Nav3D::PerformanceData performance_data;
|
||||
|
||||
struct {
|
||||
SelfList<NavRegion3D>::List regions;
|
||||
@ -178,7 +178,7 @@ public:
|
||||
return link_connection_radius;
|
||||
}
|
||||
|
||||
nav_3d::PointKey get_point_key(const Vector3 &p_pos) const;
|
||||
Nav3D::PointKey get_point_key(const Vector3 &p_pos) const;
|
||||
const Vector3 &get_merge_rasterizer_cell_size() const;
|
||||
|
||||
void query_path(NavMeshQueries3D::NavMeshPathQueryTask3D &p_query_task);
|
||||
@ -186,7 +186,7 @@ public:
|
||||
Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const;
|
||||
Vector3 get_closest_point(const Vector3 &p_point) const;
|
||||
Vector3 get_closest_point_normal(const Vector3 &p_point) const;
|
||||
nav_3d::ClosestPointQueryResult get_closest_point_info(const Vector3 &p_point) const;
|
||||
Nav3D::ClosestPointQueryResult get_closest_point_info(const Vector3 &p_point) const;
|
||||
RID get_closest_point_owner(const Vector3 &p_point) const;
|
||||
|
||||
void add_region(NavRegion3D *p_region);
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include "3d/nav_mesh_queries_3d.h"
|
||||
#include "3d/nav_region_iteration_3d.h"
|
||||
|
||||
using namespace nav_3d;
|
||||
using namespace Nav3D;
|
||||
|
||||
void NavRegion3D::set_map(NavMap3D *p_map) {
|
||||
if (map == p_map) {
|
||||
|
||||
@ -50,7 +50,7 @@ class NavRegion3D : public NavBase3D {
|
||||
bool region_dirty = true;
|
||||
bool polygons_dirty = true;
|
||||
|
||||
LocalVector<nav_3d::Polygon> navmesh_polygons;
|
||||
LocalVector<Nav3D::Polygon> navmesh_polygons;
|
||||
|
||||
real_t surface_area = 0.0;
|
||||
AABB bounds;
|
||||
@ -87,12 +87,12 @@ public:
|
||||
|
||||
void set_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh);
|
||||
|
||||
LocalVector<nav_3d::Polygon> const &get_polygons() const {
|
||||
LocalVector<Nav3D::Polygon> const &get_polygons() const {
|
||||
return navmesh_polygons;
|
||||
}
|
||||
|
||||
Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const;
|
||||
nav_3d::ClosestPointQueryResult get_closest_point_info(const Vector3 &p_point) const;
|
||||
Nav3D::ClosestPointQueryResult get_closest_point_info(const Vector3 &p_point) const;
|
||||
Vector3 get_random_point(uint32_t p_navigation_layers, bool p_uniformly) const;
|
||||
|
||||
real_t get_surface_area() const { return surface_area; }
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
struct NavBaseIteration3D;
|
||||
|
||||
namespace nav_3d {
|
||||
namespace Nav3D {
|
||||
struct Polygon;
|
||||
|
||||
union PointKey {
|
||||
@ -213,4 +213,4 @@ struct PerformanceData {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace nav_3d
|
||||
} // namespace Nav3D
|
||||
|
||||
@ -2536,7 +2536,7 @@ bool EditorExportPlatformAndroid::has_valid_username_and_password(const Ref<Edit
|
||||
|
||||
#ifdef MODULE_MONO_ENABLED
|
||||
bool _validate_dotnet_tfm(const String &required_tfm, String &r_error) {
|
||||
String assembly_name = path::get_csharp_project_name();
|
||||
String assembly_name = Path::get_csharp_project_name();
|
||||
String project_path = ProjectSettings::get_singleton()->globalize_path("res://" + assembly_name + ".csproj");
|
||||
|
||||
if (!FileAccess::exists(project_path)) {
|
||||
|
||||
@ -54,13 +54,13 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace linear {
|
||||
namespace Linear {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return c * t / d + b;
|
||||
}
|
||||
}; // namespace linear
|
||||
}; // namespace Linear
|
||||
|
||||
namespace sine {
|
||||
namespace Sine {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return -c * cos(t / d * (Math_PI / 2)) + c + b;
|
||||
}
|
||||
@ -80,9 +80,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace sine
|
||||
}; // namespace Sine
|
||||
|
||||
namespace quint {
|
||||
namespace Quint {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return c * pow(t / d, 5) + b;
|
||||
}
|
||||
@ -107,9 +107,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace quint
|
||||
}; // namespace Quint
|
||||
|
||||
namespace quart {
|
||||
namespace Quart {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return c * pow(t / d, 4) + b;
|
||||
}
|
||||
@ -134,9 +134,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace quart
|
||||
}; // namespace Quart
|
||||
|
||||
namespace quad {
|
||||
namespace Quad {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return c * pow(t / d, 2) + b;
|
||||
}
|
||||
@ -162,9 +162,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace quad
|
||||
}; // namespace Quad
|
||||
|
||||
namespace expo {
|
||||
namespace Expo {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
if (t == 0) {
|
||||
return b;
|
||||
@ -203,9 +203,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace expo
|
||||
}; // namespace Expo
|
||||
|
||||
namespace elastic {
|
||||
namespace Elastic {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
if (t == 0) {
|
||||
return b;
|
||||
@ -271,9 +271,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace elastic
|
||||
}; // namespace Elastic
|
||||
|
||||
namespace cubic {
|
||||
namespace Cubic {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
t /= d;
|
||||
return c * t * t * t + b;
|
||||
@ -301,9 +301,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace cubic
|
||||
}; // namespace Cubic
|
||||
|
||||
namespace circ {
|
||||
namespace Circ {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
t /= d;
|
||||
return -c * (sqrt(1 - t * t) - 1) + b;
|
||||
@ -331,9 +331,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace circ
|
||||
}; // namespace Circ
|
||||
|
||||
namespace bounce {
|
||||
namespace Bounce {
|
||||
static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
t /= d;
|
||||
|
||||
@ -374,9 +374,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace bounce
|
||||
}; // namespace Bounce
|
||||
|
||||
namespace back {
|
||||
namespace Back {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
float s = 1.70158f;
|
||||
t /= d;
|
||||
@ -410,9 +410,9 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace back
|
||||
}; // namespace Back
|
||||
|
||||
namespace spring {
|
||||
namespace Spring {
|
||||
static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
t /= d;
|
||||
real_t s = 1.0 - t;
|
||||
@ -439,4 +439,4 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
real_t h = c / 2;
|
||||
return in(t * 2 - d, b + h, h, d);
|
||||
}
|
||||
}; // namespace spring
|
||||
}; // namespace Spring
|
||||
|
||||
@ -39,18 +39,18 @@
|
||||
ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
|
||||
|
||||
Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
|
||||
{ &linear::in, &linear::in, &linear::in, &linear::in }, // Linear is the same for each easing.
|
||||
{ &sine::in, &sine::out, &sine::in_out, &sine::out_in },
|
||||
{ &quint::in, &quint::out, &quint::in_out, &quint::out_in },
|
||||
{ &quart::in, &quart::out, &quart::in_out, &quart::out_in },
|
||||
{ &quad::in, &quad::out, &quad::in_out, &quad::out_in },
|
||||
{ &expo::in, &expo::out, &expo::in_out, &expo::out_in },
|
||||
{ &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in },
|
||||
{ &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in },
|
||||
{ &circ::in, &circ::out, &circ::in_out, &circ::out_in },
|
||||
{ &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in },
|
||||
{ &back::in, &back::out, &back::in_out, &back::out_in },
|
||||
{ &spring::in, &spring::out, &spring::in_out, &spring::out_in },
|
||||
{ &Linear::in, &Linear::in, &Linear::in, &Linear::in }, // Linear is the same for each easing.
|
||||
{ &Sine::in, &Sine::out, &Sine::in_out, &Sine::out_in },
|
||||
{ &Quint::in, &Quint::out, &Quint::in_out, &Quint::out_in },
|
||||
{ &Quart::in, &Quart::out, &Quart::in_out, &Quart::out_in },
|
||||
{ &Quad::in, &Quad::out, &Quad::in_out, &Quad::out_in },
|
||||
{ &Expo::in, &Expo::out, &Expo::in_out, &Expo::out_in },
|
||||
{ &Elastic::in, &Elastic::out, &Elastic::in_out, &Elastic::out_in },
|
||||
{ &Cubic::in, &Cubic::out, &Cubic::in_out, &Cubic::out_in },
|
||||
{ &Circ::in, &Circ::out, &Circ::in_out, &Circ::out_in },
|
||||
{ &Bounce::in, &Bounce::out, &Bounce::in_out, &Bounce::out_in },
|
||||
{ &Back::in, &Back::out, &Back::in_out, &Back::out_in },
|
||||
{ &Spring::in, &Spring::out, &Spring::in_out, &Spring::out_in },
|
||||
};
|
||||
|
||||
void Tweener::set_tween(const Ref<Tween> &p_tween) {
|
||||
|
||||
Reference in New Issue
Block a user