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 "editor/editor_settings.h"
  34. Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_line) {
  35. Dictionary color_map;
  36. Type next_type = NONE;
  37. Type current_type = NONE;
  38. Type previous_type = NONE;
  39. String previous_text = "";
  40. int previous_column = 0;
  41. bool prev_is_char = false;
  42. bool prev_is_number = false;
  43. bool in_keyword = false;
  44. bool in_word = false;
  45. bool in_function_name = false;
  46. bool in_lambda = false;
  47. bool in_variable_declaration = false;
  48. bool in_signal_declaration = false;
  49. bool in_function_args = false;
  50. bool in_member_variable = false;
  51. bool in_node_path = false;
  52. bool in_annotation = false;
  53. bool is_hex_notation = false;
  54. bool is_bin_notation = false;
  55. bool expect_type = false;
  56. Color keyword_color;
  57. Color color;
  58. color_region_cache[p_line] = -1;
  59. int in_region = -1;
  60. if (p_line != 0) {
  61. int prev_region_line = p_line - 1;
  62. while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) {
  63. prev_region_line--;
  64. }
  65. for (int i = prev_region_line; i < p_line - 1; i++) {
  66. get_line_syntax_highlighting(i);
  67. }
  68. if (!color_region_cache.has(p_line - 1)) {
  69. get_line_syntax_highlighting(p_line - 1);
  70. }
  71. in_region = color_region_cache[p_line - 1];
  72. }
  73. const String &str = text_edit->get_line(p_line);
  74. const int line_length = str.length();
  75. Color prev_color;
  76. if (in_region != -1 && str.length() == 0) {
  77. color_region_cache[p_line] = in_region;
  78. }
  79. for (int j = 0; j < str.length(); j++) {
  80. Dictionary highlighter_info;
  81. color = font_color;
  82. bool is_char = !is_symbol(str[j]);
  83. bool is_a_symbol = is_symbol(str[j]);
  84. bool is_number = is_digit(str[j]);
  85. /* color regions */
  86. if (is_a_symbol || in_region != -1) {
  87. int from = j;
  88. if (in_region == -1) {
  89. for (; from < line_length; from++) {
  90. if (str[from] == '\\') {
  91. from++;
  92. continue;
  93. }
  94. break;
  95. }
  96. }
  97. if (from != line_length) {
  98. /* check if we are in entering a region */
  99. if (in_region == -1) {
  100. for (int c = 0; c < color_regions.size(); c++) {
  101. /* check there is enough room */
  102. int chars_left = line_length - from;
  103. int start_key_length = color_regions[c].start_key.length();
  104. int end_key_length = color_regions[c].end_key.length();
  105. if (chars_left < start_key_length) {
  106. continue;
  107. }
  108. /* search the line */
  109. bool match = true;
  110. const char32_t *start_key = color_regions[c].start_key.get_data();
  111. for (int k = 0; k < start_key_length; k++) {
  112. if (start_key[k] != str[from + k]) {
  113. match = false;
  114. break;
  115. }
  116. }
  117. if (!match) {
  118. continue;
  119. }
  120. in_region = c;
  121. from += start_key_length;
  122. /* check if it's the whole line */
  123. if (end_key_length == 0 || color_regions[c].line_only || from + end_key_length > line_length) {
  124. if (from + end_key_length > line_length) {
  125. // If it's key length and there is a '\', dont skip to highlight esc chars.
  126. if (str.find("\\", from) >= 0) {
  127. break;
  128. }
  129. }
  130. prev_color = color_regions[in_region].color;
  131. highlighter_info["color"] = color_regions[c].color;
  132. color_map[j] = highlighter_info;
  133. j = line_length;
  134. if (!color_regions[c].line_only) {
  135. color_region_cache[p_line] = c;
  136. }
  137. }
  138. break;
  139. }
  140. if (j == line_length) {
  141. continue;
  142. }
  143. }
  144. /* if we are in one find the end key */
  145. if (in_region != -1) {
  146. Color region_color = color_regions[in_region].color;
  147. if (in_node_path && (color_regions[in_region].start_key == "\"" || color_regions[in_region].start_key == "\'")) {
  148. region_color = node_path_color;
  149. }
  150. prev_color = region_color;
  151. highlighter_info["color"] = region_color;
  152. color_map[j] = highlighter_info;
  153. /* search the line */
  154. int region_end_index = -1;
  155. int end_key_length = color_regions[in_region].end_key.length();
  156. const char32_t *end_key = color_regions[in_region].end_key.get_data();
  157. for (; from < line_length; from++) {
  158. if (line_length - from < end_key_length) {
  159. // Don't break if '\' to highlight esc chars.
  160. if (str.find("\\", from) < 0) {
  161. break;
  162. }
  163. }
  164. if (!is_symbol(str[from])) {
  165. continue;
  166. }
  167. if (str[from] == '\\') {
  168. Dictionary escape_char_highlighter_info;
  169. escape_char_highlighter_info["color"] = symbol_color;
  170. color_map[from] = escape_char_highlighter_info;
  171. from++;
  172. Dictionary region_continue_highlighter_info;
  173. prev_color = region_color;
  174. region_continue_highlighter_info["color"] = region_color;
  175. color_map[from + 1] = region_continue_highlighter_info;
  176. continue;
  177. }
  178. region_end_index = from;
  179. for (int k = 0; k < end_key_length; k++) {
  180. if (end_key[k] != str[from + k]) {
  181. region_end_index = -1;
  182. break;
  183. }
  184. }
  185. if (region_end_index != -1) {
  186. break;
  187. }
  188. }
  189. previous_type = REGION;
  190. previous_text = "";
  191. previous_column = j;
  192. j = from + (end_key_length - 1);
  193. if (region_end_index == -1) {
  194. color_region_cache[p_line] = in_region;
  195. }
  196. in_region = -1;
  197. prev_is_char = false;
  198. prev_is_number = false;
  199. continue;
  200. }
  201. }
  202. }
  203. // allow ABCDEF in hex notation
  204. if (is_hex_notation && (is_hex_digit(str[j]) || is_number)) {
  205. is_number = true;
  206. } else {
  207. is_hex_notation = false;
  208. }
  209. // disallow anything not a 0 or 1
  210. if (is_bin_notation && (is_binary_digit(str[j]))) {
  211. is_number = true;
  212. } else if (is_bin_notation) {
  213. is_bin_notation = false;
  214. is_number = false;
  215. } else {
  216. is_bin_notation = false;
  217. }
  218. // check for dot or underscore or 'x' for hex notation in floating point number or 'e' for scientific notation
  219. if ((str[j] == '.' || str[j] == 'x' || str[j] == 'b' || str[j] == '_' || str[j] == 'e') && !in_word && prev_is_number && !is_number) {
  220. is_number = true;
  221. is_a_symbol = false;
  222. is_char = false;
  223. if (str[j] == 'x' && str[j - 1] == '0') {
  224. is_hex_notation = true;
  225. } else if (str[j] == 'b' && str[j - 1] == '0') {
  226. is_bin_notation = true;
  227. }
  228. }
  229. if (!in_word && (is_ascii_char(str[j]) || is_underscore(str[j])) && !is_number) {
  230. in_word = true;
  231. }
  232. if ((in_keyword || in_word) && !is_hex_notation) {
  233. is_number = false;
  234. }
  235. if (is_a_symbol && str[j] != '.' && in_word) {
  236. in_word = false;
  237. }
  238. if (!is_char) {
  239. in_keyword = false;
  240. }
  241. if (!in_keyword && is_char && !prev_is_char) {
  242. int to = j;
  243. while (to < str.length() && !is_symbol(str[to])) {
  244. to++;
  245. }
  246. String word = str.substr(j, to - j);
  247. Color col = Color();
  248. if (keywords.has(word)) {
  249. col = keywords[word];
  250. } else if (member_keywords.has(word)) {
  251. col = member_keywords[word];
  252. }
  253. if (col != Color()) {
  254. for (int k = j - 1; k >= 0; k--) {
  255. if (str[k] == '.') {
  256. col = Color(); // keyword & member indexing not allowed
  257. break;
  258. } else if (str[k] > 32) {
  259. break;
  260. }
  261. }
  262. if (col != Color()) {
  263. in_keyword = true;
  264. keyword_color = col;
  265. }
  266. }
  267. }
  268. if (!in_function_name && in_word && !in_keyword) {
  269. if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::SIGNAL)) {
  270. in_signal_declaration = true;
  271. } else {
  272. int k = j;
  273. while (k < str.length() && !is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
  274. k++;
  275. }
  276. // check for space between name and bracket
  277. while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
  278. k++;
  279. }
  280. if (str[k] == '(') {
  281. in_function_name = true;
  282. } else if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::VAR)) {
  283. in_variable_declaration = true;
  284. }
  285. // Check for lambda.
  286. if (in_function_name && previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FUNC)) {
  287. k = j - 1;
  288. while (k > 0 && (str[k] == '\t' || str[k] == ' ')) {
  289. k--;
  290. }
  291. if (str[k] == ':') {
  292. in_lambda = true;
  293. }
  294. }
  295. }
  296. }
  297. if (!in_function_name && !in_member_variable && !in_keyword && !is_number && in_word) {
  298. int k = j;
  299. while (k > 0 && !is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
  300. k--;
  301. }
  302. if (str[k] == '.') {
  303. in_member_variable = true;
  304. }
  305. }
  306. if (is_a_symbol) {
  307. if (in_function_name) {
  308. in_function_args = true;
  309. }
  310. if (in_function_args && str[j] == ')') {
  311. in_function_args = false;
  312. }
  313. if (expect_type && (prev_is_char || str[j] == '=')) {
  314. expect_type = false;
  315. }
  316. if (j > 0 && str[j] == '>' && str[j - 1] == '-') {
  317. expect_type = true;
  318. }
  319. if (in_variable_declaration || in_function_args) {
  320. int k = j;
  321. // Skip space
  322. while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
  323. k++;
  324. }
  325. if (str[k] == ':') {
  326. // has type hint
  327. expect_type = true;
  328. }
  329. }
  330. in_variable_declaration = false;
  331. in_signal_declaration = false;
  332. in_function_name = false;
  333. in_lambda = false;
  334. in_member_variable = false;
  335. }
  336. if (!in_node_path && in_region == -1 && str[j] == '$') {
  337. in_node_path = true;
  338. } else if (in_region != -1 || (is_a_symbol && str[j] != '/')) {
  339. in_node_path = false;
  340. }
  341. if (!in_annotation && in_region == -1 && str[j] == '@') {
  342. in_annotation = true;
  343. } else if (in_region != -1 || is_a_symbol) {
  344. in_annotation = false;
  345. }
  346. if (in_node_path) {
  347. next_type = NODE_PATH;
  348. color = node_path_color;
  349. } else if (in_annotation) {
  350. next_type = ANNOTATION;
  351. color = annotation_color;
  352. } else if (in_keyword) {
  353. next_type = KEYWORD;
  354. color = keyword_color;
  355. } else if (in_member_variable) {
  356. next_type = MEMBER;
  357. color = member_color;
  358. } else if (in_signal_declaration) {
  359. next_type = SIGNAL;
  360. color = member_color;
  361. } else if (in_function_name) {
  362. next_type = FUNCTION;
  363. if (!in_lambda && previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FUNC)) {
  364. color = function_definition_color;
  365. } else {
  366. color = function_color;
  367. }
  368. } else if (is_a_symbol) {
  369. next_type = SYMBOL;
  370. color = symbol_color;
  371. } else if (is_number) {
  372. next_type = NUMBER;
  373. color = number_color;
  374. } else if (expect_type) {
  375. next_type = TYPE;
  376. color = type_color;
  377. } else {
  378. next_type = IDENTIFIER;
  379. }
  380. if (next_type != current_type) {
  381. if (current_type == NONE) {
  382. current_type = next_type;
  383. } else {
  384. previous_type = current_type;
  385. current_type = next_type;
  386. // no need to store regions...
  387. if (previous_type == REGION) {
  388. previous_text = "";
  389. previous_column = j;
  390. } else {
  391. String text = str.substr(previous_column, j - previous_column).strip_edges();
  392. previous_column = j;
  393. // ignore if just whitespace
  394. if (!text.is_empty()) {
  395. previous_text = text;
  396. }
  397. }
  398. }
  399. }
  400. prev_is_char = is_char;
  401. prev_is_number = is_number;
  402. if (color != prev_color) {
  403. prev_color = color;
  404. highlighter_info["color"] = color;
  405. color_map[j] = highlighter_info;
  406. }
  407. }
  408. return color_map;
  409. }
  410. String GDScriptSyntaxHighlighter::_get_name() const {
  411. return "GDScript";
  412. }
  413. Array GDScriptSyntaxHighlighter::_get_supported_languages() const {
  414. Array languages;
  415. languages.push_back("GDScript");
  416. return languages;
  417. }
  418. void GDScriptSyntaxHighlighter::_update_cache() {
  419. keywords.clear();
  420. member_keywords.clear();
  421. color_regions.clear();
  422. color_region_cache.clear();
  423. font_color = text_edit->get_theme_color(SNAME("font_color"));
  424. symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
  425. function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
  426. number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
  427. member_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
  428. /* Engine types. */
  429. const Color types_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
  430. List<StringName> types;
  431. ClassDB::get_class_list(&types);
  432. for (const StringName &E : types) {
  433. keywords[E] = types_color;
  434. }
  435. /* User types. */
  436. const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
  437. List<StringName> global_classes;
  438. ScriptServer::get_global_class_list(&global_classes);
  439. for (const StringName &E : global_classes) {
  440. keywords[E] = usertype_color;
  441. }
  442. /* Autoloads. */
  443. OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
  444. for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) {
  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. }