From 9f5bbfc322640c33c4accde98ffaee92a7b62cab Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 18 Dec 2014 00:56:33 -0300 Subject: -improved completion options for InputEvent, shows all event types now --- modules/gdscript/gd_editor.cpp | 95 +++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 24 deletions(-) (limited to 'modules/gdscript/gd_editor.cpp') diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 09f193706c..f47b147dbf 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1625,12 +1625,6 @@ static void _find_call_arguments(GDCompletionContext& context,const GDParser::No } Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base_path, Object*p_owner, List* r_options, String &r_call_hint) { -/* bugs: - a[0]. does not work - functions should end in ( - when completing virtuals, ask for full back - - */ //print_line( p_code.replace(String::chr(0xFFFF),"")); GDParser p; @@ -1700,29 +1694,82 @@ Error GDScriptLanguage::complete_code(const String& p_code, const String& p_base } } else { - if (t.value.get_type()==Variant::NIL) { - Variant::CallError ce; - t.value=Variant::construct(t.type,NULL,0,ce); - } - if (!isfunction) { - List pl; - t.value.get_property_list(&pl); - for (List::Element *E=pl.front();E;E=E->next()) { + if (t.type==Variant::INPUT_EVENT) { + + //this is hardcoded otherwise it's not obvious + Set exclude; + + for(int i=0;ipush_back(evnames[i]); + + Variant v = ie; + + if (i==0) { + List mi; + v.get_method_list(&mi); + for (List::Element *E=mi.front();E;E=E->next()) { + r_options->push_back(E->get().name+"("); + + } + + } + + List pi; + v.get_property_list(&pi); + + for (List::Element *E=pi.front();E;E=E->next()) { + + if (i==0) + exclude.insert(E->get().name); + else if (exclude.has(E->get().name)) + continue; - if (E->get().name.find("/")==-1) - options.insert(E->get().name); + r_options->push_back(E->get().name); + } + } + return OK; + } else { + if (t.value.get_type()==Variant::NIL) { + Variant::CallError ce; + t.value=Variant::construct(t.type,NULL,0,ce); } - } - List mi; - t.value.get_method_list(&mi); - for (List::Element *E=mi.front();E;E=E->next()) { - if (E->get().arguments.size()) - options.insert(E->get().name+"("); - else - options.insert(E->get().name+"()"); + if (!isfunction) { + List pl; + t.value.get_property_list(&pl); + for (List::Element *E=pl.front();E;E=E->next()) { + + if (E->get().name.find("/")==-1) + options.insert(E->get().name); + } + } + + List mi; + t.value.get_method_list(&mi); + for (List::Element *E=mi.front();E;E=E->next()) { + if (E->get().arguments.size()) + options.insert(E->get().name+"("); + else + options.insert(E->get().name+"()"); + + } } } } -- cgit v1.2.3