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

GDScript: Misc fixes and improvements for signature generation #75691

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Apr 5, 2023

This PR fixes some type hints that are added to the function signature if the text_editor/completion/add_type_hints editor setting is enabled.

Before

1.mp4

After

2.mp4

Closes #75311.
Closes #74593.

@dalexeev dalexeev changed the title GDScript: Fix signature generation for global enums, BitMasks and Variant/void GDScript: Fix signature generation for global enums, BitFields and Variant/void Apr 5, 2023
@Chaosus Chaosus added this to the 4.1 milestone Apr 6, 2023
* Use type hints for `@GlobalScope` enums.
* Use plain `int` for `BitMask<T>`.
* Fix type hints for typed arrays.
* Use `Variant` and `void` type hints.
* Discard unnecessary class prefix.
@dalexeev dalexeev force-pushed the gds-fix-signature-generation branch from bbfccff to 9df96e9 Compare April 7, 2023 07:45
@dalexeev dalexeev changed the title GDScript: Fix signature generation for global enums, BitFields and Variant/void GDScript: Misc fixes and improvements for signature generation Apr 7, 2023
@dalexeev
Copy link
Member Author

dalexeev commented Apr 7, 2023

There is still room for improvements (add completion options to override script methods, discard unnecessary class prefix considering custom classes/scripts, etc.), but for now I'd rather stick with a small PR.

Test project: test_signature_generation.zip.

@dalexeev dalexeev marked this pull request as ready for review April 7, 2023 07:53
@dalexeev dalexeev requested a review from a team as a code owner April 7, 2023 07:53
Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR was reviewed by the GDScript team. This fixes an important issue that will help users to write better typed code.

As discussed, this autocomplete feature will only work, currently, with virtual native functions. So we don't have to worry, for now, to autocomplete typed functions for non-typed existing functions.

Thanks for your PR! Very appreciated.

@YuriSizov YuriSizov merged commit a7276f1 into godotengine:master Apr 14, 2023
@YuriSizov
Copy link
Contributor

Thanks!

@dalexeev
Copy link
Member Author

I think cherry-pick for 4.0 makes sense. Not necessarily all the PR, but changes in modules/gdscript/gdscript_analyzer.cpp fix significant bugs (#75311, #74593).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants