Merge pull request #96693 from HolonProduction/annotation-arg-hint

Autocompletion: Add arghint for annotations
This commit is contained in:
Rémi Verschelde 2024-10-02 15:00:58 +02:00
commit 0b2446101c
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 14 additions and 7 deletions

View file

@ -1640,23 +1640,29 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali
advance();
// Arguments.
push_completion_call(annotation);
make_completion_context(COMPLETION_ANNOTATION_ARGUMENTS, annotation, 0);
int argument_index = 0;
do {
make_completion_context(COMPLETION_ANNOTATION_ARGUMENTS, annotation, argument_index);
set_last_completion_call_arg(argument_index);
if (check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE)) {
// Allow for trailing comma.
break;
}
make_completion_context(COMPLETION_ANNOTATION_ARGUMENTS, annotation, argument_index);
set_last_completion_call_arg(argument_index++);
ExpressionNode *argument = parse_expression(false);
if (argument == nullptr) {
push_error("Expected expression as the annotation argument.");
valid = false;
continue;
} else {
annotation->arguments.push_back(argument);
if (argument->type == Node::LITERAL) {
override_completion_context(argument, COMPLETION_ANNOTATION_ARGUMENTS, annotation, argument_index);
}
}
annotation->arguments.push_back(argument);
argument_index++;
} while (match(GDScriptTokenizer::Token::COMMA) && !is_at_end());
pop_multiline();