From 75f395c2a0dd3d1af4f53585145dc22f76ecd134 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 29 May 2018 23:16:59 -0300 Subject: Use type hints to improve completion - Allow type hints to be completed. - Use type information to infer completion candidates. - Show typed function signature in tooltip. - Add type hints when completing declaration from virtual functions (optional). --- editor/connections_dialog.cpp | 4 +- editor/editor_settings.cpp | 1 + modules/gdscript/gdscript_editor.cpp | 235 +++++++++++++++++++++++++++-------- 3 files changed, 186 insertions(+), 54 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 8933fd7fe8..c4f4e28fec 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -820,7 +820,9 @@ void ConnectionsDock::update_tree() { if (i > 0) signaldesc += ", "; String tname = "var"; - if (pi.type != Variant::NIL) { + if (pi.type == Variant::OBJECT && pi.class_name != StringName()) { + tname = pi.class_name.operator String(); + } else if (pi.type != Variant::NIL) { tname = Variant::get_type_name(pi.type); } signaldesc += tname + " " + (pi.name == "" ? String("arg " + itos(i)) : pi.name); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4cfdb6f6d3..9736eb0969 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -404,6 +404,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); _initial_set("text_editor/files/restore_scripts_on_load", true); _initial_set("text_editor/completion/complete_file_paths", true); + _initial_set("text_editor/completion/add_type_hints", false); _initial_set("docks/scene_tree/start_create_dialog_fully_expanded", false); _initial_set("docks/scene_tree/draw_relationship_lines", false); diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 8389f57761..a09c7a45cc 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -53,21 +53,45 @@ void GDScriptLanguage::get_string_delimiters(List *p_delimiters) const { p_delimiters->push_back("' '"); } Ref