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

Method complete

servers/rendering/shader_language.cpp:11363–12070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11361}
11362
11363Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint) {
11364 clear();
11365 is_shader_inc = p_info.is_include;
11366
11367 code = p_code;
11368 varying_function_names = p_info.varying_function_names;
11369
11370 nodes = nullptr;
11371 global_shader_uniform_get_type_func = p_info.global_shader_uniform_type_func;
11372
11373 shader = alloc_node<ShaderNode>();
11374 _parse_shader(p_info.functions, p_info.render_modes, p_info.stencil_modes, p_info.shader_types);
11375
11376#ifdef DEBUG_ENABLED
11377 // Adds context keywords.
11378 if (keyword_completion_context != CF_UNSPECIFIED) {
11379 constexpr int sz = std::size(keyword_list);
11380 for (int i = 0; i < sz; i++) {
11381 if (keyword_list[i].flags == CF_UNSPECIFIED) {
11382 break; // Ignore hint keywords (parsed below).
11383 }
11384 if (keyword_list[i].flags & keyword_completion_context) {
11385 if (keyword_list[i].excluded_shader_types.has(shader_type_identifier) || keyword_list[i].excluded_functions.has(current_function)) {
11386 continue;
11387 }
11388 ScriptLanguage::CodeCompletionOption option(keyword_list[i].text, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
11389 r_options->push_back(option);
11390 }
11391 }
11392 }
11393#endif // DEBUG_ENABLED
11394
11395 switch (completion_type) {
11396 case COMPLETION_NONE: {
11397 //do nothing
11398 return OK;
11399 } break;
11400 case COMPLETION_SHADER_TYPE: {
11401 for (const String &shader_type : p_info.shader_types) {
11402 ScriptLanguage::CodeCompletionOption option(shader_type, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
11403 r_options->push_back(option);
11404 }
11405 return OK;
11406 } break;
11407 case COMPLETION_RENDER_MODE: {
11408 if (is_shader_inc) {
11409 for (int i = 0; i < RenderingServer::SHADER_MAX; i++) {
11410 const Vector<ModeInfo> modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i));
11411
11412 for (int j = 0; j < modes.size(); j++) {
11413 const ModeInfo &info = modes[j];
11414
11415 if (!info.options.is_empty()) {
11416 bool found = false;
11417
11418 for (int k = 0; k < info.options.size(); k++) {
11419 if (shader->render_modes.has(String(info.name) + "_" + String(info.options[k]))) {
11420 found = true;

Callers 1

_code_complete_scriptMethod · 0.80

Calls 15

clearFunction · 0.85
ShaderModeEnum · 0.85
itosFunction · 0.85
substrMethod · 0.80
find_charMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50
StringNameClass · 0.50
hasMethod · 0.45
push_backMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected