summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_text_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/script_text_editor.cpp')
-rw-r--r--editor/plugins/script_text_editor.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 02168a4c97..176df7efb8 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -759,7 +759,7 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri
return NULL;
}
-static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script> > &r_scripts) {
+static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) {
if (p_current->get_owner() != p_base && p_base != p_current)
return;
@@ -780,14 +780,14 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
ERR_FAIL_COND(!get_tree());
- Set<Ref<Script> > scripts;
+ Set<Ref<Script>> scripts;
Node *base = get_tree()->get_edited_scene_root();
if (base) {
_find_changed_scripts_for_external_editor(base, base, scripts);
}
- for (Set<Ref<Script> >::Element *E = scripts.front(); E; E = E->next()) {
+ for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) {
Ref<Script> script = E->get();
@@ -980,6 +980,23 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
}
+void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
+
+ TextEdit *text_edit = code_editor->get_text_edit();
+
+ Node *base = get_tree()->get_edited_scene_root();
+ if (base) {
+ base = _find_node_for_script(base, base, script);
+ }
+
+ ScriptLanguage::LookupResult result;
+ if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
+ text_edit->set_highlighted_word(p_symbol);
+ } else {
+ text_edit->set_highlighted_word(String());
+ }
+}
+
void ScriptTextEditor::update_toggle_scripts_button() {
if (code_editor != NULL) {
code_editor->update_toggle_scripts_button();
@@ -1769,6 +1786,7 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->set_code_complete_func(_code_complete_scripts, this);
code_editor->get_text_edit()->connect("breakpoint_toggled", callable_mp(this, &ScriptTextEditor::_breakpoint_toggled));
code_editor->get_text_edit()->connect("symbol_lookup", callable_mp(this, &ScriptTextEditor::_lookup_symbol));
+ code_editor->get_text_edit()->connect("symbol_validate", callable_mp(this, &ScriptTextEditor::_validate_symbol));
code_editor->get_text_edit()->connect("info_clicked", callable_mp(this, &ScriptTextEditor::_lookup_connections));
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
code_editor->show_toggle_scripts_button();