summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_text_editor.cpp33
-rw-r--r--editor/plugins/script_text_editor.h4
2 files changed, 37 insertions, 0 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index f1ed984fee..2a6b4ee173 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -63,6 +63,7 @@ void ScriptTextEditor::apply_code() {
//print_line("applying code");
script->set_source_code(code_editor->get_text_edit()->get_text());
script->update_exports();
+ _update_member_keywords();
}
Ref<Script> ScriptTextEditor::get_edited_script() const {
@@ -70,6 +71,37 @@ Ref<Script> ScriptTextEditor::get_edited_script() const {
return script;
}
+void ScriptTextEditor::_update_member_keywords() {
+ member_keywords.clear();
+ code_editor->get_text_edit()->clear_member_keywords();
+ Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
+
+ StringName instance_base = script->get_instance_base_type();
+
+ if (instance_base == StringName())
+ return;
+ List<PropertyInfo> plist;
+ ClassDB::get_property_list(instance_base, &plist);
+
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
+ String name = E->get().name;
+ if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP)
+ continue;
+ if (name.find("/") != -1)
+ continue;
+
+ code_editor->get_text_edit()->add_member_keyword(name, member_variable_color);
+ }
+
+ List<String> clist;
+ ClassDB::get_integer_constant_list(instance_base, &clist);
+
+ for (List<String>::Element *E = clist.front(); E; E = E->next()) {
+
+ code_editor->get_text_edit()->add_member_keyword(E->get(), member_variable_color);
+ }
+}
+
void ScriptTextEditor::_load_theme_settings() {
TextEdit *text_edit = code_editor->get_text_edit();
@@ -563,6 +595,7 @@ void ScriptTextEditor::_validate_script() {
if (!script->is_tool()) {
script->set_source_code(text);
script->update_exports();
+ _update_member_keywords();
//script->reload(); //will update all the variables in property editors
}
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index ebbe865cee..22e8fbce25 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -44,6 +44,8 @@ class ScriptTextEditor : public ScriptEditorBase {
Vector<String> functions;
+ Vector<String> member_keywords;
+
HBoxContainer *edit_hb;
MenuButton *edit_menu;
@@ -58,6 +60,8 @@ class ScriptTextEditor : public ScriptEditorBase {
int color_line;
String color_args;
+ void _update_member_keywords();
+
struct ColorsCache {
Color symbol_color;
Color keyword_color;