fix: Return only scenes for script owners on LSP completion
Fix: #36680
(cherry picked from commit 2f08f4ef4e
)
This commit is contained in:
parent
ecfe9c24a2
commit
5736e43fe4
|
@ -401,19 +401,23 @@ void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *GDScriptWorkspace::_get_owner_node(String p_path) {
|
Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
|
||||||
Node *owner_node = NULL;
|
Node *owner_scene_node = NULL;
|
||||||
List<String> owners;
|
List<String> owners;
|
||||||
|
|
||||||
_get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners);
|
_get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners);
|
||||||
|
|
||||||
if (owners.size() > 0) {
|
for (int i = 0; i < owners.size(); i++) {
|
||||||
NodePath owner_path = owners[0];
|
NodePath owner_path = owners[i];
|
||||||
Ref<PackedScene> owner_res = ResourceLoader::load(owner_path);
|
RES owner_res = ResourceLoader::load(owner_path);
|
||||||
owner_node = owner_res->instance(PackedScene::GEN_EDIT_STATE_DISABLED);
|
if (Object::cast_to<PackedScene>(owner_res.ptr())) {
|
||||||
|
Ref<PackedScene> owner_packed_scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*owner_res));
|
||||||
|
owner_scene_node = owner_packed_scene->instance();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return owner_node;
|
return owner_scene_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) {
|
void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) {
|
||||||
|
@ -423,11 +427,11 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||||
bool forced = false;
|
bool forced = false;
|
||||||
|
|
||||||
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
|
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
|
||||||
Node *owner_node = _get_owner_node(path);
|
Node *owner_scene_node = _get_owner_scene_node(path);
|
||||||
String code = parser->get_text_for_completion(p_params.position);
|
String code = parser->get_text_for_completion(p_params.position);
|
||||||
GDScriptLanguage::get_singleton()->complete_code(code, path, owner_node, r_options, forced, call_hint);
|
GDScriptLanguage::get_singleton()->complete_code(code, path, owner_scene_node, r_options, forced, call_hint);
|
||||||
if (owner_node) {
|
if (owner_scene_node) {
|
||||||
memdelete(owner_node);
|
memdelete(owner_scene_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class GDScriptWorkspace : public Reference {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);
|
void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);
|
||||||
Node *_get_owner_node(String p_path);
|
Node *_get_owner_scene_node(String p_path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
Loading…
Reference in New Issue