Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Expose the EditorScriptHighlighter::_create() method to GDExtension #98929

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/classes/EditorSyntaxHighlighter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<tutorials>
</tutorials>
<methods>
<method name="_create" qualifiers="virtual const">
<return type="EditorSyntaxHighlighter" />
<description>
Virtual method which creates a new instance of the syntax highlighter.
</description>
</method>
<method name="_get_name" qualifiers="virtual const">
<return type="String" />
<description>
Expand Down
11 changes: 8 additions & 3 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ PackedStringArray EditorSyntaxHighlighter::_get_supported_languages() const {

Ref<EditorSyntaxHighlighter> EditorSyntaxHighlighter::_create() const {
Ref<EditorSyntaxHighlighter> syntax_highlighter;
syntax_highlighter.instantiate();
if (get_script_instance()) {
syntax_highlighter->set_script(get_script_instance()->get_script());
if (GDVIRTUAL_IS_OVERRIDDEN(_create)) {
GDVIRTUAL_CALL(_create, syntax_highlighter);
} else {
syntax_highlighter.instantiate();
if (get_script_instance()) {
syntax_highlighter->set_script(get_script_instance()->get_script());
}
}
return syntax_highlighter;
}
Expand All @@ -98,6 +102,7 @@ void EditorSyntaxHighlighter::_bind_methods() {

GDVIRTUAL_BIND(_get_name)
GDVIRTUAL_BIND(_get_supported_languages)
GDVIRTUAL_BIND(_create)
}

////
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/script_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class EditorSyntaxHighlighter : public SyntaxHighlighter {

GDVIRTUAL0RC(String, _get_name)
GDVIRTUAL0RC(PackedStringArray, _get_supported_languages)
GDVIRTUAL0RC(Ref<EditorSyntaxHighlighter>, _create)

public:
virtual String _get_name() const;
Expand Down
Loading