Skip to content

Commit 7b9e7b9

Browse files
committed
Merge pull request #98929 from dsnopek/editor-syntax-highlighter-create
Expose the `EditorScriptHighlighter::_create()` method to GDExtension
2 parents ca1e478 + 1474ecc commit 7b9e7b9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/classes/EditorSyntaxHighlighter.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
<tutorials>
1111
</tutorials>
1212
<methods>
13+
<method name="_create" qualifiers="virtual const">
14+
<return type="EditorSyntaxHighlighter" />
15+
<description>
16+
Virtual method which creates a new instance of the syntax highlighter.
17+
</description>
18+
</method>
1319
<method name="_get_name" qualifiers="virtual const">
1420
<return type="String" />
1521
<description>

editor/plugins/script_editor_plugin.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ PackedStringArray EditorSyntaxHighlighter::_get_supported_languages() const {
9191

9292
Ref<EditorSyntaxHighlighter> EditorSyntaxHighlighter::_create() const {
9393
Ref<EditorSyntaxHighlighter> syntax_highlighter;
94-
syntax_highlighter.instantiate();
95-
if (get_script_instance()) {
96-
syntax_highlighter->set_script(get_script_instance()->get_script());
94+
if (GDVIRTUAL_IS_OVERRIDDEN(_create)) {
95+
GDVIRTUAL_CALL(_create, syntax_highlighter);
96+
} else {
97+
syntax_highlighter.instantiate();
98+
if (get_script_instance()) {
99+
syntax_highlighter->set_script(get_script_instance()->get_script());
100+
}
97101
}
98102
return syntax_highlighter;
99103
}
@@ -103,6 +107,7 @@ void EditorSyntaxHighlighter::_bind_methods() {
103107

104108
GDVIRTUAL_BIND(_get_name)
105109
GDVIRTUAL_BIND(_get_supported_languages)
110+
GDVIRTUAL_BIND(_create)
106111
}
107112

108113
////

editor/plugins/script_editor_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class EditorSyntaxHighlighter : public SyntaxHighlighter {
6161

6262
GDVIRTUAL0RC(String, _get_name)
6363
GDVIRTUAL0RC(PackedStringArray, _get_supported_languages)
64+
GDVIRTUAL0RC(Ref<EditorSyntaxHighlighter>, _create)
6465

6566
public:
6667
virtual String _get_name() const;

0 commit comments

Comments
 (0)