MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _find_identifiers

Function _find_identifiers

modules/gdscript/gdscript_editor.cpp:1525–1643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1523}
1524
1525static void _find_identifiers(const GDScriptParser::CompletionContext &p_context, bool p_only_functions, bool p_add_braces, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
1526 if (!p_only_functions && p_context.current_suite) {
1527 // This includes function parameters, since they are also locals.
1528 _find_identifiers_in_suite(p_context.current_suite, r_result);
1529 }
1530
1531 if (p_context.current_class) {
1532 _find_identifiers_in_class(p_context.current_class, p_only_functions, false, (!p_context.current_function || p_context.current_function->is_static), false, p_add_braces, r_result, p_recursion_depth);
1533 }
1534
1535 List<StringName> functions;
1536 GDScriptUtilityFunctions::get_function_list(&functions);
1537
1538 for (const StringName &E : functions) {
1539 MethodInfo function = GDScriptUtilityFunctions::get_function_info(E);
1540 ScriptLanguage::CodeCompletionOption option(String(E), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
1541 if (p_add_braces) {
1542 if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) {
1543 option.insert_text += "(";
1544 option.display += U"(\u2026)";
1545 } else {
1546 option.insert_text += "()";
1547 option.display += "()";
1548 }
1549 }
1550 r_result.insert(option.display, option);
1551 }
1552
1553 if (p_only_functions) {
1554 return;
1555 }
1556
1557 _find_built_in_variants(r_result);
1558
1559 static const char *_keywords[] = {
1560 "true", "false", "PI", "TAU", "INF", "NAN", "null", "self", "super",
1561 "break", "breakpoint", "continue", "pass", "return",
1562 nullptr
1563 };
1564
1565 const char **kw = _keywords;
1566 while (*kw) {
1567 ScriptLanguage::CodeCompletionOption option(*kw, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
1568 r_result.insert(option.display, option);
1569 kw++;
1570 }
1571
1572 static const char *_keywords_with_space[] = {
1573 "and", "not", "or", "in", "as", "class", "class_name", "extends", "is", "func", "signal", "await",
1574 "const", "enum", "static", "var", "if", "elif", "else", "for", "match", "when", "while",
1575 nullptr
1576 };
1577
1578 const char **kws = _keywords_with_space;
1579 while (*kws) {
1580 ScriptLanguage::CodeCompletionOption option(*kws, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
1581 option.insert_text += " ";
1582 r_result.insert(option.display, option);

Callers 1

complete_codeMethod · 0.85

Calls 10

_find_built_in_variantsFunction · 0.85
_find_global_enumsFunction · 0.85
sizeMethod · 0.65
StringClass · 0.50
insertMethod · 0.45
has_singletonMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected