浏览代码

Move add_syntax_highlighter bind to ScriptEditorBase

Paulb23 3 年之前
父节点
当前提交
3010bca41b

+ 1 - 1
doc/classes/EditorSyntaxHighlighter.xml

@@ -5,7 +5,7 @@
 	</brief_description>
 	<description>
 		Base syntax highlighter resource all editor syntax highlighters extend from, it is used in the [ScriptEditor].
-		Add a syntax highlighter to an individual script by calling ScriptEditorBase._add_syntax_highlighter (currently not working). To apply to all scripts on open, call [method ScriptEditor.register_syntax_highlighter]
+		Add a syntax highlighter to an individual script by calling [method ScriptEditorBase.add_syntax_highlighter]. To apply to all scripts on open, call [method ScriptEditor.register_syntax_highlighter]
 	</description>
 	<tutorials>
 	</tutorials>

+ 7 - 0
doc/classes/ScriptEditorBase.xml

@@ -9,6 +9,13 @@
 	<tutorials>
 	</tutorials>
 	<methods>
+		<method name="add_syntax_highlighter">
+			<return type="void" />
+			<argument index="0" name="highlighter" type="EditorSyntaxHighlighter" />
+			<description>
+				Adds a [EditorSyntaxHighlighter] to the open script.
+			</description>
+		</method>
 		<method name="get_base_editor" qualifiers="const">
 			<return type="Control" />
 			<description>

+ 1 - 0
editor/plugins/script_editor_plugin.cpp

@@ -214,6 +214,7 @@ Ref<EditorSyntaxHighlighter> EditorPlainTextSyntaxHighlighter::_create() const {
 
 void ScriptEditorBase::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_base_editor"), &ScriptEditorBase::get_base_editor);
+	ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &ScriptEditorBase::add_syntax_highlighter);
 
 	ADD_SIGNAL(MethodInfo("name_changed"));
 	ADD_SIGNAL(MethodInfo("edited_script_changed"));

+ 0 - 2
editor/plugins/script_text_editor.cpp

@@ -1341,8 +1341,6 @@ void ScriptTextEditor::_bind_methods() {
 	ClassDB::bind_method("_get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw);
 	ClassDB::bind_method("_can_drop_data_fw", &ScriptTextEditor::can_drop_data_fw);
 	ClassDB::bind_method("_drop_data_fw", &ScriptTextEditor::drop_data_fw);
-
-	ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &ScriptTextEditor::add_syntax_highlighter);
 }
 
 Control *ScriptTextEditor::get_edit_menu() {

+ 0 - 4
editor/plugins/text_editor.cpp

@@ -407,10 +407,6 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
 	code_editor->convert_case(p_case);
 }
 
-void TextEditor::_bind_methods() {
-	ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &TextEditor::add_syntax_highlighter);
-}
-
 static ScriptEditorBase *create_editor(const RES &p_resource) {
 	if (Object::cast_to<TextFile>(*p_resource)) {
 		return memnew(TextEditor);

+ 0 - 2
editor/plugins/text_editor.h

@@ -87,8 +87,6 @@ private:
 	};
 
 protected:
-	static void _bind_methods();
-
 	void _edit_option(int p_op);
 	void _make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position);
 	void _text_edit_gui_input(const Ref<InputEvent> &ev);

+ 0 - 2
modules/visual_script/visual_script_editor.cpp

@@ -4262,8 +4262,6 @@ void VisualScriptEditor::_bind_methods() {
 	ClassDB::bind_method("_update_members", &VisualScriptEditor::_update_members);
 
 	ClassDB::bind_method("_generic_search", &VisualScriptEditor::_generic_search);
-
-	ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &VisualScriptEditor::add_syntax_highlighter);
 }
 
 VisualScriptEditor::VisualScriptEditor() {