| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/script/script_editor_plugin.h" |
| 34 |
|
| 35 |
class GDScriptSyntaxHighlighter : public EditorSyntaxHighlighter { |
| 36 |
GDCLASS(GDScriptSyntaxHighlighter, EditorSyntaxHighlighter) |
| 37 |
|
| 38 |
private: |
| 39 |
struct ColorRegion { |
| 40 |
enum Type { |
| 41 |
TYPE_NONE, |
| 42 |
TYPE_STRING, |
| 43 |
TYPE_MULTILINE_STRING, |
| 44 |
TYPE_COMMENT, |
| 45 |
TYPE_CODE_REGION, |
| 46 |
}; |
| 47 |
|
| 48 |
Type type = TYPE_NONE; |
| 49 |
Color color; |
| 50 |
String start_key; |
| 51 |
String end_key; |
| 52 |
bool line_only = false; |
| 53 |
bool r_prefix = false; |
| 54 |
bool is_string = false; |
| 55 |
bool is_comment = false; |
| 56 |
}; |
| 57 |
Vector<ColorRegion> color_regions; |
| 58 |
HashMap<int, int> color_region_cache; |
| 59 |
|
| 60 |
HashMap<StringName, Color> class_names; |
| 61 |
HashMap<StringName, Color> reserved_keywords; |
| 62 |
HashMap<StringName, Color> member_keywords; |
| 63 |
HashSet<StringName> global_functions; |
| 64 |
|
| 65 |
enum Type { |
| 66 |
NONE, |
| 67 |
REGION, |
| 68 |
NODE_PATH, |
| 69 |
NODE_REF, |
| 70 |
ANNOTATION, |
| 71 |
STRING_NAME, |
| 72 |
SYMBOL, |
| 73 |
NUMBER, |
| 74 |
FUNCTION, |
| 75 |
SIGNAL, |
| 76 |
KEYWORD, |
| 77 |
MEMBER, |
| 78 |
IDENTIFIER, |
| 79 |
TYPE, |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
Color font_color; |
| 84 |
Color symbol_color; |
| 85 |
Color function_color; |
| 86 |
Color global_function_color; |
| 87 |
Color function_definition_color; |
| 88 |
Color built_in_type_color; |
| 89 |
Color number_color; |
| 90 |
Color member_variable_color; |
| 91 |
Color string_color; |
| 92 |
Color placeholder_color; |
| 93 |
Color node_path_color; |
| 94 |
Color node_ref_color; |
| 95 |
Color annotation_color; |
| 96 |
Color string_name_color; |
| 97 |
Color type_color; |
| 98 |
|
| 99 |
enum CommentMarkerLevel { |
| 100 |
COMMENT_MARKER_CRITICAL, |
| 101 |
COMMENT_MARKER_WARNING, |
| 102 |
COMMENT_MARKER_NOTICE, |
| 103 |
COMMENT_MARKER_MAX, |
| 104 |
}; |
| 105 |
Color comment_marker_colors[COMMENT_MARKER_MAX]; |
| 106 |
HashMap<String, CommentMarkerLevel> comment_markers; |
| 107 |
|
| 108 |
void add_color_region(ColorRegion::Type p_type, const String &p_start_key, const String &p_end_key, const Color &p_color, bool p_line_only = false, bool p_r_prefix = false); |
| 109 |
|
| 110 |
public: |
| 111 |
virtual void _update_cache() override; |
| 112 |
virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override; |
| 113 |
|
| 114 |
virtual String _get_name() const override; |
| 115 |
virtual PackedStringArray _get_supported_languages() const override; |
| 116 |
|
| 117 |
virtual Ref<EditorSyntaxHighlighter> _create() const override; |
| 118 |
}; |