gdscript_highlighter.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*************************************************************************/
  2. /* gdscript_highlighter.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "gdscript_highlighter.h"
  31. #include "../gdscript.h"
  32. #include "../gdscript_tokenizer.h"
  33. #include "core/config/project_settings.h"
  34. #include "editor/editor_settings.h"
  35. Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_line) {
  36. Dictionary color_map;
  37. Type next_type = NONE;
  38. Type current_type = NONE;
  39. Type previous_type = NONE;
  40. String previous_text = "";
  41. int previous_column = 0;
  42. bool prev_is_char = false;
  43. bool prev_is_number = false;
  44. bool in_keyword = false;
  45. bool in_word = false;
  46. bool in_function_name = false;
  47. bool in_lambda = false;
  48. bool in_variable_declaration = false;
  49. bool in_signal_declaration = false;
  50. bool in_function_args = false;
  51. bool in_member_variable = false;
  52. bool in_node_path = false;
  53. bool in_annotation = false;
  54. bool is_hex_notation = false;
  55. bool is_bin_notation = false;
  56. bool expect_type = false;
  57. Color keyword_color;
  58. Color color;
  59. color_region_cache[p_line] = -1;
  60. int in_region = -1;
  61. if (p_line != 0) {
  62. int prev_region_line = p_line - 1;
  63. while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) {
  64. prev_region_line--;
  65. }
  66. for (int i = prev_region_line; i < p_line - 1; i++) {
  67. get_line_syntax_highlighting(i);
  68. }
  69. if (!color_region_cache.has(p_line - 1)) {
  70. get_line_syntax_highlighting(p_line - 1);
  71. }
  72. in_region = color_region_cache[p_line - 1];
  73. }
  74. const String &str = text_edit->get_line(p_line);
  75. const int line_length = str.length();
  76. Color prev_color;
  77. if (in_region != -1 && str.length() == 0) {
  78. color_region_cache[p_line] = in_region;
  79. }
  80. for (int j = 0; j < str.length(); j++) {
  81. Dictionary highlighter_info;
  82. color = font_color;
  83. bool is_char = !is_symbol(str[j]);
  84. bool is_a_symbol = is_symbol(str[j]);
  85. bool is_number = is_digit(str[j]);
  86. /* color regions */
  87. if (is_a_symbol || in_region != -1) {
  88. int from = j;
  89. if (in_region == -1) {
  90. for (; from < line_length; from++) {
  91. if (str[from] == '\\') {
  92. from++;
  93. continue;
  94. }
  95. break;
  96. }
  97. }
  98. if (from != line_length) {
  99. /* check if we are in entering a region */
  100. if (in_region == -1) {
  101. for (int c = 0; c < color_regions.size(); c++) {
  102. /* check there is enough room */
  103. int chars_left = line_length - from;
  104. int start_key_length = color_regions[c].start_key.length();
  105. int end_key_length = color_regions[c].end_key.length();
  106. if (chars_left < start_key_length) {
  107. continue;
  108. }
  109. /* search the line */
  110. bool match = true;
  111. const char32_t *start_key = color_regions[c].start_key.get_data();
  112. for (int k = 0; k < start_key_length; k++) {
  113. if (start_key[k] != str[from + k]) {
  114. match = false;
  115. break;
  116. }
  117. }
  118. if (!match) {
  119. continue;
  120. }
  121. in_region = c;
  122. from += start_key_length;
  123. /* check if it's the whole line */
  124. if (end_key_length == 0 || color_regions[c].line_only || from + end_key_length > line_length) {
  125. if (from + end_key_length > line_length) {
  126. // If it's key length and there is a '\', dont skip to highlight esc chars.
  127. if (str.find("\\", from) >= 0) {
  128. break;
  129. }
  130. }
  131. prev_color = color_regions[in_region].color;
  132. highlighter_info["color"] = color_regions[c].color;
  133. color_map[j] = highlighter_info;
  134. j = line_length;
  135. if (!color_regions[c].line_only) {
  136. color_region_cache[p_line] = c;
  137. }
  138. }
  139. break;
  140. }
  141. if (j == line_length) {
  142. continue;
  143. }
  144. }
  145. /* if we are in one find the end key */
  146. if (in_region != -1) {
  147. Color region_color = color_regions[in_region].color;
  148. if (in_node_path && (color_regions[in_region].start_key == "\"" || color_regions[in_region].start_key == "\'")) {
  149. region_color = node_path_color;
  150. }
  151. prev_color = region_color;
  152. highlighter_info["color"] = region_color;
  153. color_map[j] = highlighter_info;
  154. /* search the line */
  155. int region_end_index = -1;
  156. int end_key_length = color_regions[in_region].end_key.length();
  157. const char32_t *end_key = color_regions[in_region].end_key.get_data();
  158. for (; from < line_length; from++) {
  159. if (line_length - from < end_key_length) {
  160. // Don't break if '\' to highlight esc chars.
  161. if (str.find("\\", from) < 0) {
  162. break;
  163. }
  164. }
  165. if (!is_symbol(str[from])) {
  166. continue;
  167. }
  168. if (str[from] == '\\') {
  169. Dictionary escape_char_highlighter_info;
  170. escape_char_highlighter_info["color"] = symbol_color;
  171. color_map[from] = escape_char_highlighter_info;
  172. from++;
  173. Dictionary region_continue_highlighter_info;
  174. prev_color = region_color;
  175. region_continue_highlighter_info["color"] = region_color;
  176. color_map[from + 1] = region_continue_highlighter_info;
  177. continue;
  178. }
  179. region_end_index = from;
  180. for (int k = 0; k < end_key_length; k++) {
  181. if (end_key[k] != str[from + k]) {
  182. region_end_index = -1;
  183. break;
  184. }
  185. }
  186. if (region_end_index != -1) {
  187. break;
  188. }
  189. }
  190. previous_type = REGION;
  191. previous_text = "";
  192. previous_column = j;
  193. j = from + (end_key_length - 1);
  194. if (region_end_index == -1) {
  195. color_region_cache[p_line] = in_region;
  196. }
  197. in_region = -1;
  198. prev_is_char = false;
  199. prev_is_number = false;
  200. continue;
  201. }
  202. }
  203. }
  204. // allow ABCDEF in hex notation
  205. if (is_hex_notation && (is_hex_digit(str[j]) || is_number)) {
  206. is_number = true;
  207. } else {
  208. is_hex_notation = false;
  209. }
  210. // disallow anything not a 0 or 1
  211. if (is_bin_notation && (is_binary_digit(str[j]))) {
  212. is_number = true;
  213. } else if (is_bin_notation) {
  214. is_bin_notation = false;
  215. is_number = false;
  216. } else {
  217. is_bin_notation = false;
  218. }
  219. // check for dot or underscore or 'x' for hex notation in floating point number or 'e' for scientific notation
  220. if ((str[j] == '.' || str[j] == 'x' || str[j] == 'b' || str[j] == '_' || str[j] == 'e') && !in_word && prev_is_number && !is_number) {
  221. is_number = true;
  222. is_a_symbol = false;
  223. is_char = false;
  224. if (str[j] == 'x' && str[j - 1] == '0') {
  225. is_hex_notation = true;
  226. } else if (str[j] == 'b' && str[j - 1] == '0') {
  227. is_bin_notation = true;
  228. }
  229. }
  230. if (!in_word && (is_ascii_char(str[j]) || is_underscore(str[j])) && !is_number) {
  231. in_word = true;
  232. }
  233. if ((in_keyword || in_word) && !is_hex_notation) {
  234. is_number = false;
  235. }
  236. if (is_a_symbol && str[j] != '.' && in_word) {
  237. in_word = false;
  238. }
  239. if (!is_char) {
  240. in_keyword = false;
  241. }
  242. if (!in_keyword && is_char && !prev_is_char) {
  243. int to = j;
  244. while (to < str.length() && !is_symbol(str[to])) {
  245. to++;
  246. }
  247. String word = str.substr(j, to - j);
  248. Color col = Color();
  249. if (keywords.has(word)) {
  250. col = keywords[word];
  251. } else if (member_keywords.has(word)) {
  252. col = member_keywords[word];
  253. }
  254. if (col != Color()) {
  255. for (int k = j - 1; k >= 0; k--) {
  256. if (str[k] == '.') {
  257. col = Color(); // keyword & member indexing not allowed
  258. break;
  259. } else if (str[k] > 32) {
  260. break;
  261. }
  262. }
  263. if (col != Color()) {
  264. in_keyword = true;
  265. keyword_color = col;
  266. }
  267. }
  268. }
  269. if (!in_function_name && in_word && !in_keyword) {
  270. if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::SIGNAL)) {
  271. in_signal_declaration = true;
  272. } else {
  273. int k = j;
  274. while (k < str.length() && !is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
  275. k++;
  276. }
  277. // check for space between name and bracket
  278. while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
  279. k++;
  280. }
  281. if (str[k] == '(') {
  282. in_function_name = true;
  283. } else if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::VAR)) {
  284. in_variable_declaration = true;
  285. }
  286. // Check for lambda.
  287. if (in_function_name && previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FUNC)) {
  288. k = j - 1;
  289. while (k > 0 && (str[k] == '\t' || str[k] == ' ')) {
  290. k--;
  291. }
  292. if (str[k] == ':') {
  293. in_lambda = true;
  294. }
  295. }
  296. }
  297. }
  298. if (!in_function_name && !in_member_variable && !in_keyword && !is_number && in_word) {
  299. int k = j;
  300. while (k > 0 && !is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
  301. k--;
  302. }
  303. if (str[k] == '.') {
  304. in_member_variable = true;
  305. }
  306. }
  307. if (is_a_symbol) {
  308. if (in_function_name) {
  309. in_function_args = true;
  310. }
  311. if (in_function_args && str[j] == ')') {
  312. in_function_args = false;
  313. }
  314. if (expect_type && (prev_is_char || str[j] == '=')) {
  315. expect_type = false;
  316. }
  317. if (j > 0 && str[j] == '>' && str[j - 1] == '-') {
  318. expect_type = true;
  319. }
  320. if (in_variable_declaration || in_function_args) {
  321. int k = j;
  322. // Skip space
  323. while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
  324. k++;
  325. }
  326. if (str[k] == ':') {
  327. // has type hint
  328. expect_type = true;
  329. }
  330. }
  331. in_variable_declaration = false;
  332. in_signal_declaration = false;
  333. in_function_name = false;
  334. in_lambda = false;
  335. in_member_variable = false;
  336. }
  337. if (!in_node_path && in_region == -1 && (str[j] == '$' || str[j] == '%')) {
  338. in_node_path = true;
  339. } else if (in_region != -1 || (is_a_symbol && str[j] != '/' && str[j] != '%')) {
  340. in_node_path = false;
  341. }
  342. if (!in_annotation && in_region == -1 && str[j] == '@') {
  343. in_annotation = true;
  344. } else if (in_region != -1 || is_a_symbol) {
  345. in_annotation = false;
  346. }
  347. if (in_node_path) {
  348. next_type = NODE_PATH;
  349. color = node_path_color;
  350. } else if (in_annotation) {
  351. next_type = ANNOTATION;
  352. color = annotation_color;
  353. } else if (in_keyword) {
  354. next_type = KEYWORD;
  355. color = keyword_color;
  356. } else if (in_member_variable) {
  357. next_type = MEMBER;
  358. color = member_color;
  359. } else if (in_signal_declaration) {
  360. next_type = SIGNAL;
  361. color = member_color;
  362. } else if (in_function_name) {
  363. next_type = FUNCTION;
  364. if (!in_lambda && previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FUNC)) {
  365. color = function_definition_color;
  366. } else {
  367. color = function_color;
  368. }
  369. } else if (is_a_symbol) {
  370. next_type = SYMBOL;
  371. color = symbol_color;
  372. } else if (is_number) {
  373. next_type = NUMBER;
  374. color = number_color;
  375. } else if (expect_type) {
  376. next_type = TYPE;
  377. color = type_color;
  378. } else {
  379. next_type = IDENTIFIER;
  380. }
  381. if (next_type != current_type) {
  382. if (current_type == NONE) {
  383. current_type = next_type;
  384. } else {
  385. previous_type = current_type;
  386. current_type = next_type;
  387. // no need to store regions...
  388. if (previous_type == REGION) {
  389. previous_text = "";
  390. previous_column = j;
  391. } else {
  392. String text = str.substr(previous_column, j - previous_column).strip_edges();
  393. previous_column = j;
  394. // ignore if just whitespace
  395. if (!text.is_empty()) {
  396. previous_text = text;
  397. }
  398. }
  399. }
  400. }
  401. prev_is_char = is_char;
  402. prev_is_number = is_number;
  403. if (color != prev_color) {
  404. prev_color = color;
  405. highlighter_info["color"] = color;
  406. color_map[j] = highlighter_info;
  407. }
  408. }
  409. return color_map;
  410. }
  411. String GDScriptSyntaxHighlighter::_get_name() const {
  412. return "GDScript";
  413. }
  414. Array GDScriptSyntaxHighlighter::_get_supported_languages() const {
  415. Array languages;
  416. languages.push_back("GDScript");
  417. return languages;
  418. }
  419. void GDScriptSyntaxHighlighter::_update_cache() {
  420. keywords.clear();
  421. member_keywords.clear();
  422. color_regions.clear();
  423. color_region_cache.clear();
  424. font_color = text_edit->get_theme_color(SNAME("font_color"));
  425. symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
  426. function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
  427. number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
  428. member_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
  429. /* Engine types. */
  430. const Color types_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
  431. List<StringName> types;
  432. ClassDB::get_class_list(&types);
  433. for (const StringName &E : types) {
  434. keywords[E] = types_color;
  435. }
  436. /* User types. */
  437. const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
  438. List<StringName> global_classes;
  439. ScriptServer::get_global_class_list(&global_classes);
  440. for (const StringName &E : global_classes) {
  441. keywords[E] = usertype_color;
  442. }
  443. /* Autoloads. */
  444. for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : ProjectSettings::get_singleton()->get_autoload_list()) {
  445. const ProjectSettings::AutoloadInfo &info = E.value;
  446. if (info.is_singleton) {
  447. keywords[info.name] = usertype_color;
  448. }
  449. }
  450. const GDScriptLanguage *gdscript = GDScriptLanguage::get_singleton();
  451. /* Core types. */
  452. const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
  453. List<String> core_types;
  454. gdscript->get_core_type_words(&core_types);
  455. for (const String &E : core_types) {
  456. keywords[StringName(E)] = basetype_color;
  457. }
  458. /* Reserved words. */
  459. const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
  460. const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
  461. List<String> keyword_list;
  462. gdscript->get_reserved_words(&keyword_list);
  463. for (const String &E : keyword_list) {
  464. if (gdscript->is_control_flow_keyword(E)) {
  465. keywords[StringName(E)] = control_flow_keyword_color;
  466. } else {
  467. keywords[StringName(E)] = keyword_color;
  468. }
  469. }
  470. /* Comments */
  471. const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
  472. List<String> comments;
  473. gdscript->get_comment_delimiters(&comments);
  474. for (const String &comment : comments) {
  475. String beg = comment.get_slice(" ", 0);
  476. String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
  477. add_color_region(beg, end, comment_color, end.is_empty());
  478. }
  479. /* Strings */
  480. const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
  481. List<String> strings;
  482. gdscript->get_string_delimiters(&strings);
  483. for (const String &string : strings) {
  484. String beg = string.get_slice(" ", 0);
  485. String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
  486. add_color_region(beg, end, string_color, end.is_empty());
  487. }
  488. const Ref<Script> script = _get_edited_resource();
  489. if (script.is_valid()) {
  490. /* Member types. */
  491. const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
  492. StringName instance_base = script->get_instance_base_type();
  493. if (instance_base != StringName()) {
  494. List<PropertyInfo> plist;
  495. ClassDB::get_property_list(instance_base, &plist);
  496. for (const PropertyInfo &E : plist) {
  497. String name = E.name;
  498. if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) {
  499. continue;
  500. }
  501. if (name.contains("/")) {
  502. continue;
  503. }
  504. member_keywords[name] = member_variable_color;
  505. }
  506. List<String> clist;
  507. ClassDB::get_integer_constant_list(instance_base, &clist);
  508. for (const String &E : clist) {
  509. member_keywords[E] = member_variable_color;
  510. }
  511. }
  512. }
  513. const String text_edit_color_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme");
  514. const bool godot_2_theme = text_edit_color_theme == "Godot 2";
  515. if (godot_2_theme || EditorSettings::get_singleton()->is_dark_theme()) {
  516. function_definition_color = Color(0.4, 0.9, 1.0);
  517. node_path_color = Color(0.39, 0.76, 0.35);
  518. annotation_color = Color(1.0, 0.7, 0.45);
  519. } else {
  520. function_definition_color = Color(0.0, 0.65, 0.73);
  521. node_path_color = Color(0.32, 0.55, 0.29);
  522. annotation_color = Color(0.8, 0.5, 0.25);
  523. }
  524. EDITOR_DEF("text_editor/theme/highlighting/gdscript/function_definition_color", function_definition_color);
  525. EDITOR_DEF("text_editor/theme/highlighting/gdscript/node_path_color", node_path_color);
  526. EDITOR_DEF("text_editor/theme/highlighting/gdscript/annotation_color", annotation_color);
  527. if (text_edit_color_theme == "Default" || godot_2_theme) {
  528. EditorSettings::get_singleton()->set_initial_value(
  529. "text_editor/theme/highlighting/gdscript/function_definition_color",
  530. function_definition_color,
  531. true);
  532. EditorSettings::get_singleton()->set_initial_value(
  533. "text_editor/theme/highlighting/gdscript/node_path_color",
  534. node_path_color,
  535. true);
  536. EditorSettings::get_singleton()->set_initial_value(
  537. "text_editor/theme/highlighting/gdscript/annotation_color",
  538. annotation_color,
  539. true);
  540. }
  541. function_definition_color = EDITOR_GET("text_editor/theme/highlighting/gdscript/function_definition_color");
  542. node_path_color = EDITOR_GET("text_editor/theme/highlighting/gdscript/node_path_color");
  543. annotation_color = EDITOR_GET("text_editor/theme/highlighting/gdscript/annotation_color");
  544. type_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
  545. }
  546. void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, const String &p_end_key, const Color &p_color, bool p_line_only) {
  547. for (int i = 0; i < p_start_key.length(); i++) {
  548. ERR_FAIL_COND_MSG(!is_symbol(p_start_key[i]), "color regions must start with a symbol");
  549. }
  550. if (p_end_key.length() > 0) {
  551. for (int i = 0; i < p_end_key.length(); i++) {
  552. ERR_FAIL_COND_MSG(!is_symbol(p_end_key[i]), "color regions must end with a symbol");
  553. }
  554. }
  555. int at = 0;
  556. for (int i = 0; i < color_regions.size(); i++) {
  557. ERR_FAIL_COND_MSG(color_regions[i].start_key == p_start_key, "color region with start key '" + p_start_key + "' already exists.");
  558. if (p_start_key.length() < color_regions[i].start_key.length()) {
  559. at++;
  560. }
  561. }
  562. ColorRegion color_region;
  563. color_region.color = p_color;
  564. color_region.start_key = p_start_key;
  565. color_region.end_key = p_end_key;
  566. color_region.line_only = p_line_only;
  567. color_regions.insert(at, color_region);
  568. clear_highlighting_cache();
  569. }
  570. Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
  571. Ref<GDScriptSyntaxHighlighter> syntax_highlighter;
  572. syntax_highlighter.instantiate();
  573. return syntax_highlighter;
  574. }