Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LSP] Inconsistent autocomplete suggestion with get_node and typed variables. #43136

Closed
linkpy opened this issue Oct 27, 2020 · 4 comments
Closed

Comments

@linkpy
Copy link
Contributor

linkpy commented Oct 27, 2020

Godot version:
3.2.3

OS/device including version:
Linux 5.4.0 (Linux Mint)

Issue description:
If the node doesn't exist, the LSP doesn't give the right autocompletion (checked in debug mode, the LSP server's message doesn't contain any members of the Sprite class and thus is a bug on the LSP server) :

image

If the node exists, the autocompletion works as intended :

image

The autocomplete works as intended too when the node doesn't exists if the get_node call is cast :

image

Linked with godotengine/godot-vscode-plugin#235.

Steps to reproduce:
See above screenshots.

Minimal reproduction project:
/

@Razoric480
Copy link
Contributor

This is consistent with the built-in GDScript editor. In fact, this is a case where the language server does a better job than the GDScript editor. If you take the above code in the screenshots and try to get is_pixel_opaque() from a node that does not exist, both will not return anything. If you try with a node that does exist, and the scene is closed, the language server will find it but the GDScript editor will not. If the scene is opened, both find it.

It's still wrong, mind you, but it's not an LSP bug, as the LSP forwards the call to GDScriptLanguage::complete_code(), which is also called by the GDScript editor.

Because its actual type is assumed to be "Node" because the scene is closed or get_node() found nothing because the node doesn't exist, that's what it uses. Unless we actively cast to force the return type, it ignores the variable's static type hint.

@timothyqiu
Copy link
Member

I encountered a similar issue in the GDScript editor.

onready var foo: Spatial = get_parent()

Here foo should be Spatial and get_parent() returns Node. But the final type is a Viewport when the scene is open because the script is on the root node.

@cdemirer
Copy link
Contributor

cdemirer commented Jul 7, 2022

Also see: #42005

@HolonProduction
Copy link
Member

Closing as duplicate of #53318

@HolonProduction HolonProduction closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants