1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Add defines to completion list in shaders

This commit is contained in:
Yuri Rubinsky
2022-09-26 15:48:35 +03:00
parent 3472bdd6b6
commit 344aa610e3
3 changed files with 14 additions and 4 deletions

View File

@@ -385,13 +385,14 @@ static void _complete_include_paths(List<ScriptLanguage::CodeCompletionOption> *
void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options) {
List<ScriptLanguage::CodeCompletionOption> pp_options;
List<ScriptLanguage::CodeCompletionOption> pp_defines;
ShaderPreprocessor preprocessor;
String code;
complete_from_path = (shader.is_valid() ? shader->get_path() : shader_inc->get_path()).get_base_dir();
if (!complete_from_path.ends_with("/")) {
complete_from_path += "/";
}
preprocessor.preprocess(p_code, "", code, nullptr, nullptr, nullptr, nullptr, &pp_options, _complete_include_paths);
preprocessor.preprocess(p_code, "", code, nullptr, nullptr, nullptr, nullptr, &pp_options, &pp_defines, _complete_include_paths);
complete_from_path = String();
if (pp_options.size()) {
for (const ScriptLanguage::CodeCompletionOption &E : pp_options) {
@@ -399,6 +400,9 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa
}
return;
}
for (const ScriptLanguage::CodeCompletionOption &E : pp_defines) {
r_options->push_back(E);
}
ShaderLanguage sl;
String calltip;