From e905e8f145ef5d91aa6f8200bf415569e28d5967 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 8 Apr 2021 16:12:22 +0200 Subject: Highlight control flow keywords with a different color This makes them easier to distinguish from other keywords. --- servers/rendering/shader_language.cpp | 14 ++++++++++++++ servers/rendering/shader_language.h | 1 + 2 files changed, 15 insertions(+) (limited to 'servers/rendering') diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 0d6d3f5e13..a81306b97d 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -2969,6 +2969,20 @@ void ShaderLanguage::get_keyword_list(List *r_keywords) { } } +bool ShaderLanguage::is_control_flow_keyword(String p_keyword) { + return p_keyword == "break" || + p_keyword == "case" || + p_keyword == "continue" || + p_keyword == "default" || + p_keyword == "do" || + p_keyword == "else" || + p_keyword == "for" || + p_keyword == "if" || + p_keyword == "return" || + p_keyword == "switch" || + p_keyword == "while"; +} + void ShaderLanguage::get_builtin_funcs(List *r_keywords) { Set kws; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 470f3d38d5..e00f4dce19 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -748,6 +748,7 @@ public: static uint32_t get_type_size(DataType p_type); static void get_keyword_list(List *r_keywords); + static bool is_control_flow_keyword(String p_keyword); static void get_builtin_funcs(List *r_keywords); struct BuiltInInfo { -- cgit v1.2.3