@@ -430,6 +430,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
430430 expect_type = false ;
431431 } else if (member_keywords.has (word)) {
432432 col = member_keywords[word];
433+ in_member_variable = true ;
433434 }
434435
435436 if (col != Color ()) {
@@ -442,7 +443,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
442443 }
443444 }
444445
445- if (col != Color ()) {
446+ if (!in_member_variable && col != Color ()) {
446447 in_keyword = true ;
447448 keyword_color = col;
448449 }
@@ -627,7 +628,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
627628 color = keyword_color;
628629 } else if (in_signal_declaration) {
629630 next_type = SIGNAL;
630- color = member_color ;
631+ color = member_variable_color ;
631632 } else if (in_function_name) {
632633 next_type = FUNCTION;
633634 if (!in_lambda && in_function_declaration) {
@@ -646,7 +647,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
646647 color = type_color;
647648 } else if (in_member_variable) {
648649 next_type = MEMBER;
649- color = member_color ;
650+ color = member_variable_color ;
650651 } else {
651652 next_type = IDENTIFIER;
652653 }
@@ -709,7 +710,7 @@ void GDScriptSyntaxHighlighter::_update_cache() {
709710 symbol_color = EDITOR_GET (" text_editor/theme/highlighting/symbol_color" );
710711 function_color = EDITOR_GET (" text_editor/theme/highlighting/function_color" );
711712 number_color = EDITOR_GET (" text_editor/theme/highlighting/number_color" );
712- member_color = EDITOR_GET (" text_editor/theme/highlighting/member_variable_color" );
713+ member_variable_color = EDITOR_GET (" text_editor/theme/highlighting/member_variable_color" );
713714
714715 /* Engine types. */
715716 const Color types_color = EDITOR_GET (" text_editor/theme/highlighting/engine_type_color" );
@@ -779,7 +780,7 @@ void GDScriptSyntaxHighlighter::_update_cache() {
779780 global_functions.insert (E);
780781 }
781782
782- /* Comments */
783+ /* Comments. */
783784 const Color comment_color = EDITOR_GET (" text_editor/theme/highlighting/comment_color" );
784785 for (const String &comment : gdscript->get_comment_delimiters ()) {
785786 String beg = comment.get_slicec (' ' , 0 );
@@ -811,15 +812,14 @@ void GDScriptSyntaxHighlighter::_update_cache() {
811812 add_color_region (ColorRegion::TYPE_MULTILINE_STRING, " \"\"\" " , " \"\"\" " , string_color, false , true );
812813 add_color_region (ColorRegion::TYPE_MULTILINE_STRING, " '''" , " '''" , string_color, false , true );
813814
814- const Ref<Script> scr = _get_edited_resource ();
815+ /* Members. */
816+ Ref<Script> scr = _get_edited_resource ();
815817 if (scr.is_valid ()) {
816- /* Member types. */
817- const Color member_variable_color = EDITOR_GET (" text_editor/theme/highlighting/member_variable_color" );
818818 StringName instance_base = scr->get_instance_base_type ();
819819 if (instance_base != StringName ()) {
820- List<PropertyInfo> plist ;
821- ClassDB::get_property_list (instance_base, &plist );
822- for (const PropertyInfo &E : plist ) {
820+ List<PropertyInfo> property_list ;
821+ ClassDB::get_property_list (instance_base, &property_list );
822+ for (const PropertyInfo &E : property_list ) {
823823 String prop_name = E.name ;
824824 if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) {
825825 continue ;
@@ -830,12 +830,61 @@ void GDScriptSyntaxHighlighter::_update_cache() {
830830 member_keywords[prop_name] = member_variable_color;
831831 }
832832
833- List<String> clist;
834- ClassDB::get_integer_constant_list (instance_base, &clist);
835- for (const String &E : clist) {
833+ List<MethodInfo> signal_list;
834+ ClassDB::get_signal_list (instance_base, &signal_list);
835+ for (const MethodInfo &E : signal_list) {
836+ member_keywords[E.name ] = member_variable_color;
837+ }
838+
839+ // For callables.
840+ List<MethodInfo> method_list;
841+ ClassDB::get_method_list (instance_base, &method_list);
842+ for (const MethodInfo &E : method_list) {
843+ member_keywords[E.name ] = member_variable_color;
844+ }
845+
846+ List<String> constant_list;
847+ ClassDB::get_integer_constant_list (instance_base, &constant_list);
848+ for (const String &E : constant_list) {
836849 member_keywords[E] = member_variable_color;
837850 }
838851 }
852+
853+ List<PropertyInfo> scr_property_list;
854+ scr->get_script_property_list (&scr_property_list);
855+ for (const PropertyInfo &E : scr_property_list) {
856+ String prop_name = E.name ;
857+ if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) {
858+ continue ;
859+ }
860+ if (prop_name.contains_char (' /' )) {
861+ continue ;
862+ }
863+ member_keywords[prop_name] = member_variable_color;
864+ }
865+
866+ List<MethodInfo> scr_signal_list;
867+ scr->get_script_signal_list (&scr_signal_list);
868+ for (const MethodInfo &E : scr_signal_list) {
869+ member_keywords[E.name ] = member_variable_color;
870+ }
871+
872+ // For callables.
873+ List<MethodInfo> scr_method_list;
874+ scr->get_script_method_list (&scr_method_list);
875+ for (const MethodInfo &E : scr_method_list) {
876+ member_keywords[E.name ] = member_variable_color;
877+ }
878+
879+ Ref<Script> scr_class = scr;
880+ while (scr_class.is_valid ()) {
881+ HashMap<StringName, Variant> scr_constant_list;
882+ scr_class->get_constants (&scr_constant_list);
883+ for (const KeyValue<StringName, Variant> &E : scr_constant_list) {
884+ member_keywords[E.key .operator String ()] = member_variable_color;
885+ }
886+ scr_class = scr_class->get_base_script ();
887+ }
839888 }
840889
841890 const String text_edit_color_theme = EDITOR_GET (" text_editor/theme/color_theme" );
0 commit comments