From bec6fd0c37978af446dd6664c21dcca875981cd4 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Sat, 7 Dec 2024 10:19:56 +0300 Subject: [PATCH] Code Editor: Add documentation tooltips --- core/object/script_language.h | 33 +- core/object/script_language_extension.cpp | 5 +- core/object/script_language_extension.h | 38 +- doc/classes/CodeEdit.xml | 13 + doc/classes/ScriptExtension.xml | 5 + doc/classes/ScriptLanguageExtension.xml | 8 +- editor/editor_help.cpp | 328 +++++++++++++++--- editor/editor_help.h | 15 +- editor/editor_inspector.cpp | 16 +- editor/plugins/script_text_editor.cpp | 170 +++++++-- editor/plugins/script_text_editor.h | 2 + modules/gdscript/editor/gdscript_docgen.cpp | 11 + modules/gdscript/editor/gdscript_docgen.h | 1 + modules/gdscript/gdscript.cpp | 16 +- modules/gdscript/gdscript.h | 8 +- modules/gdscript/gdscript_editor.cpp | 154 ++++++-- modules/gdscript/gdscript_parser.cpp | 33 ++ .../language_server/gdscript_workspace.cpp | 9 +- modules/mono/csharp_script.h | 1 + scene/gui/code_edit.cpp | 42 +++ scene/gui/code_edit.h | 16 +- 21 files changed, 751 insertions(+), 173 deletions(-) diff --git a/core/object/script_language.h b/core/object/script_language.h index 31d6638e58e8..e7f312f5aed3 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -150,6 +150,7 @@ class Script : public Resource { virtual Error reload(bool p_keep_state = false) = 0; #ifdef TOOLS_ENABLED + virtual StringName get_doc_class_name() const = 0; virtual Vector get_documentation() const = 0; virtual String get_class_icon_path() const = 0; virtual PropertyInfo get_class_category() const; @@ -181,7 +182,7 @@ class Script : public Resource { virtual int get_member_line(const StringName &p_member) const { return -1; } virtual void get_constants(HashMap *p_constants) {} - virtual void get_members(HashSet *p_constants) {} + virtual void get_members(HashSet *p_members) {} virtual bool is_placeholder_fallback_enabled() const { return false; } @@ -340,25 +341,43 @@ class ScriptLanguage : public Object { virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; } enum LookupResultType { - LOOKUP_RESULT_SCRIPT_LOCATION, + LOOKUP_RESULT_SCRIPT_LOCATION, // Use if none of the options below apply. LOOKUP_RESULT_CLASS, LOOKUP_RESULT_CLASS_CONSTANT, LOOKUP_RESULT_CLASS_PROPERTY, LOOKUP_RESULT_CLASS_METHOD, LOOKUP_RESULT_CLASS_SIGNAL, LOOKUP_RESULT_CLASS_ENUM, - LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE, + LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE, // Deprecated. LOOKUP_RESULT_CLASS_ANNOTATION, - LOOKUP_RESULT_MAX + LOOKUP_RESULT_LOCAL_CONSTANT, + LOOKUP_RESULT_LOCAL_VARIABLE, + LOOKUP_RESULT_MAX, }; struct LookupResult { LookupResultType type; - Ref