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: Add some checks for @tool and @icon #76065

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

dalexeev
Copy link
Member

Closes #76059.

@dalexeev dalexeev requested a review from a team as a code owner April 14, 2023 17:47
@YuriSizov YuriSizov added this to the 4.1 milestone Apr 14, 2023
@YuriSizov
Copy link
Contributor

Should probably add tests for those cases.

@dalexeev dalexeev force-pushed the gds-check-tool-and-icon branch from a9e97b5 to 93f54c5 Compare April 14, 2023 18:53
@dalexeev
Copy link
Member Author

Should probably add tests for those cases.

Done.

@YuriSizov
Copy link
Contributor

Thanks! Btw, why err if a non-global class has an icon? We can still use them in the editor. I even has a PR adding support for those.

@dalexeev
Copy link
Member Author

I even has a PR adding support for those.

At least it doesn't currently work. This is even written in the docs, but there is no check in the parser.

Add a custom icon to the current script. The script must be registered as a global class using the class_name keyword for this to have a visible effect.

Btw, why err if a non-global class has an icon?

Probably because the editor reads this data from the .godot/global_script_class_cache.cfg file that only contains global named classes.

@YuriSizov
Copy link
Contributor

YuriSizov commented Apr 14, 2023

Yes, in my PR I add a way to get it directly from the script.

#75656

@dalexeev
Copy link
Member Author

Yes, in my PR I add a way to get it directly from the script.

Okay, then I will remove that part. I will not delete the obsolete note in the docs, please do it within #75656.

@dalexeev dalexeev force-pushed the gds-check-tool-and-icon branch from 93f54c5 to 9c4a8e2 Compare April 14, 2023 19:21
@dalexeev dalexeev force-pushed the gds-check-tool-and-icon branch from 9c4a8e2 to dbc3c82 Compare April 20, 2023 04:45
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

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

I think this check is a good idea, even though it is fixing a very minor problem.

@@ -3686,6 +3686,12 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation)
}

bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p_node) {
#ifdef DEBUG_ENABLED
if (this->_is_tool) {
Copy link
Member

Choose a reason for hiding this comment

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

this-> is redundant but it's consistent with the below, so I guess it's OK.

@akien-mga akien-mga merged commit a1d2396 into godotengine:master Apr 20, 2023
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the gds-check-tool-and-icon branch April 20, 2023 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No error if a script has multiple @tool annotations at the top.
5 participants