feat: updated godot version
This commit is contained in:
parent
0c508b0831
commit
42b028dbb5
4694 changed files with 236470 additions and 401376 deletions
|
|
@ -36,7 +36,6 @@
|
|||
#include "core/config/project_settings.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "scene/main/multiplayer_api.h"
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
@ -236,22 +235,12 @@ void GDScriptParser::push_error(const String &p_message, const Node *p_origin) {
|
|||
// TODO: Improve error reporting by pointing at source code.
|
||||
// TODO: Errors might point at more than one place at once (e.g. show previous declaration).
|
||||
panic_mode = true;
|
||||
ParserError err;
|
||||
err.message = p_message;
|
||||
|
||||
// TODO: Improve positional information.
|
||||
if (p_origin == nullptr) {
|
||||
err.start_line = previous.start_line;
|
||||
err.start_column = previous.start_column;
|
||||
err.end_line = previous.end_line;
|
||||
err.end_column = previous.end_column;
|
||||
errors.push_back({ p_message, previous.start_line, previous.start_column });
|
||||
} else {
|
||||
err.start_line = p_origin->start_line;
|
||||
err.start_column = p_origin->start_column;
|
||||
err.end_line = p_origin->end_line;
|
||||
err.end_column = p_origin->end_column;
|
||||
errors.push_back({ p_message, p_origin->start_line, p_origin->start_column });
|
||||
}
|
||||
|
||||
errors.push_back(err);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
@ -290,9 +279,7 @@ void GDScriptParser::apply_pending_warnings() {
|
|||
warning.code = pw.code;
|
||||
warning.symbols = pw.symbols;
|
||||
warning.start_line = pw.source->start_line;
|
||||
warning.start_column = pw.source->start_column;
|
||||
warning.end_line = pw.source->end_line;
|
||||
warning.end_column = pw.source->end_column;
|
||||
|
||||
if (pw.treated_as_error) {
|
||||
push_error(warning.get_message() + String(" (Warning treated as error.)"), pw.source);
|
||||
|
|
@ -704,12 +691,12 @@ void GDScriptParser::parse_program() {
|
|||
current_class = head;
|
||||
bool can_have_class_or_extends = true;
|
||||
|
||||
#define PUSH_PENDING_ANNOTATIONS_TO_HEAD \
|
||||
if (!annotation_stack.is_empty()) { \
|
||||
#define PUSH_PENDING_ANNOTATIONS_TO_HEAD \
|
||||
if (!annotation_stack.is_empty()) { \
|
||||
for (AnnotationNode *annot : annotation_stack) { \
|
||||
head->annotations.push_back(annot); \
|
||||
} \
|
||||
annotation_stack.clear(); \
|
||||
head->annotations.push_back(annot); \
|
||||
} \
|
||||
annotation_stack.clear(); \
|
||||
}
|
||||
|
||||
while (!check(GDScriptTokenizer::Token::TK_EOF)) {
|
||||
|
|
@ -938,8 +925,6 @@ bool GDScriptParser::has_class(const GDScriptParser::ClassNode *p_class) const {
|
|||
GDScriptParser::ClassNode *GDScriptParser::parse_class(bool p_is_static) {
|
||||
ClassNode *n_class = alloc_node<ClassNode>();
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, n_class);
|
||||
|
||||
ClassNode *previous_class = current_class;
|
||||
current_class = n_class;
|
||||
n_class->outer = previous_class;
|
||||
|
|
@ -996,12 +981,6 @@ void GDScriptParser::parse_class_name() {
|
|||
current_class->fqcn = String(current_class->identifier->name);
|
||||
}
|
||||
|
||||
if (script_path.begins_with("res://") && script_path.contains("::")) {
|
||||
push_error(R"("class_name" isn't allowed in built-in scripts.)");
|
||||
}
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, current_class);
|
||||
|
||||
if (match(GDScriptTokenizer::Token::EXTENDS)) {
|
||||
// Allow extends on the same line.
|
||||
parse_extends();
|
||||
|
|
@ -1235,8 +1214,6 @@ GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static) {
|
|||
GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static, bool p_allow_property) {
|
||||
VariableNode *variable = alloc_node<VariableNode>();
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, variable);
|
||||
|
||||
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected variable name after "var".)")) {
|
||||
complete_extents(variable);
|
||||
return nullptr;
|
||||
|
|
@ -1473,8 +1450,6 @@ void GDScriptParser::parse_property_getter(VariableNode *p_variable) {
|
|||
GDScriptParser::ConstantNode *GDScriptParser::parse_constant(bool p_is_static) {
|
||||
ConstantNode *constant = alloc_node<ConstantNode>();
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, constant);
|
||||
|
||||
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected constant name after "const".)")) {
|
||||
complete_extents(constant);
|
||||
return nullptr;
|
||||
|
|
@ -1543,8 +1518,6 @@ GDScriptParser::ParameterNode *GDScriptParser::parse_parameter() {
|
|||
GDScriptParser::SignalNode *GDScriptParser::parse_signal(bool p_is_static) {
|
||||
SignalNode *signal = alloc_node<SignalNode>();
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, signal);
|
||||
|
||||
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected signal name after "signal".)")) {
|
||||
complete_extents(signal);
|
||||
return nullptr;
|
||||
|
|
@ -1591,8 +1564,6 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {
|
|||
EnumNode *enum_node = alloc_node<EnumNode>();
|
||||
bool named = false;
|
||||
|
||||
make_completion_context(COMPLETION_DECLARATION, enum_node);
|
||||
|
||||
if (match(GDScriptTokenizer::Token::IDENTIFIER)) {
|
||||
enum_node->identifier = parse_identifier();
|
||||
named = true;
|
||||
|
|
@ -3483,9 +3454,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre
|
|||
if (!check(GDScriptTokenizer::Token::PERIOD)) {
|
||||
make_completion_context(COMPLETION_SUPER, call);
|
||||
}
|
||||
if (check(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
|
||||
push_multiline(true);
|
||||
advance();
|
||||
push_multiline(true);
|
||||
if (match(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
|
||||
// Implicit call to the parent method of the same name.
|
||||
if (current_function == nullptr) {
|
||||
push_error(R"(Cannot use implicit "super" call outside of a function.)");
|
||||
|
|
@ -3502,18 +3472,15 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre
|
|||
consume(GDScriptTokenizer::Token::PERIOD, R"(Expected "." or "(" after "super".)");
|
||||
make_completion_context(COMPLETION_SUPER_METHOD, call);
|
||||
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected function name after ".".)")) {
|
||||
pop_multiline();
|
||||
complete_extents(call);
|
||||
return nullptr;
|
||||
}
|
||||
IdentifierNode *identifier = parse_identifier();
|
||||
call->callee = identifier;
|
||||
call->function_name = identifier->name;
|
||||
|
||||
if (check(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
|
||||
push_multiline(true);
|
||||
advance();
|
||||
} else {
|
||||
push_error(R"(Expected "(" after function name.)");
|
||||
if (!consume(GDScriptTokenizer::Token::PARENTHESIS_OPEN, R"(Expected "(" after function name.)")) {
|
||||
pop_multiline();
|
||||
complete_extents(call);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -3935,24 +3902,20 @@ enum DocLineState {
|
|||
DOC_LINE_IN_KBD,
|
||||
};
|
||||
|
||||
static void _process_doc_line(const String &p_line, String &r_text, const String &p_space_prefix, DocLineState &r_state) {
|
||||
static String _process_doc_line(const String &p_line, const String &p_text, const String &p_space_prefix, DocLineState &r_state) {
|
||||
String line = p_line;
|
||||
if (r_state == DOC_LINE_NORMAL) {
|
||||
line = line.lstrip(" \t");
|
||||
line = line.strip_edges(true, false);
|
||||
} else {
|
||||
line = line.trim_prefix(p_space_prefix);
|
||||
}
|
||||
|
||||
String line_join;
|
||||
if (!r_text.is_empty()) {
|
||||
if (!p_text.is_empty()) {
|
||||
if (r_state == DOC_LINE_NORMAL) {
|
||||
if (r_text.ends_with("[/codeblock]")) {
|
||||
if (p_text.ends_with("[/codeblock]")) {
|
||||
line_join = "\n";
|
||||
} else if (r_text.ends_with("[br]")) {
|
||||
// We want to replace `[br][br]` with `\n` (paragraph), so we move the trailing `[br]` here.
|
||||
r_text = r_text.left(-4); // `-len("[br]")`.
|
||||
line = "[br]" + line;
|
||||
} else if (!r_text.ends_with("\n")) {
|
||||
} else if (!p_text.ends_with("[br]")) {
|
||||
line_join = " ";
|
||||
}
|
||||
} else {
|
||||
|
|
@ -3982,14 +3945,7 @@ static void _process_doc_line(const String &p_line, String &r_text, const String
|
|||
from = rb_pos + 1;
|
||||
|
||||
String tag = line.substr(lb_pos + 1, rb_pos - lb_pos - 1);
|
||||
if (tag == "br") {
|
||||
if (line.substr(from, 4) == "[br]") { // `len("[br]")`.
|
||||
// Replace `[br][br]` with `\n` (paragraph).
|
||||
result += line.substr(buffer_start, lb_pos - buffer_start) + '\n';
|
||||
from += 4; // `len("[br]")`.
|
||||
buffer_start = from;
|
||||
}
|
||||
} else if (tag == "code" || tag.begins_with("code ")) {
|
||||
if (tag == "code" || tag.begins_with("code ")) {
|
||||
r_state = DOC_LINE_IN_CODE;
|
||||
} else if (tag == "codeblock" || tag.begins_with("codeblock ")) {
|
||||
if (lb_pos == 0) {
|
||||
|
|
@ -4057,10 +4013,10 @@ static void _process_doc_line(const String &p_line, String &r_text, const String
|
|||
|
||||
result += line.substr(buffer_start);
|
||||
if (r_state == DOC_LINE_NORMAL) {
|
||||
result = result.rstrip(" \t");
|
||||
result = result.strip_edges(false, true);
|
||||
}
|
||||
|
||||
r_text += line_join + result;
|
||||
return line_join + result;
|
||||
}
|
||||
|
||||
bool GDScriptParser::has_comment(int p_line, bool p_must_be_doc) {
|
||||
|
|
@ -4123,7 +4079,7 @@ GDScriptParser::MemberDocData GDScriptParser::parse_doc_comment(int p_line, bool
|
|||
}
|
||||
}
|
||||
|
||||
_process_doc_line(doc_line, result.description, space_prefix, state);
|
||||
result.description += _process_doc_line(doc_line, result.description, space_prefix, state);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -4233,9 +4189,9 @@ GDScriptParser::ClassDocData GDScriptParser::parse_class_doc_comment(int p_line,
|
|||
}
|
||||
|
||||
if (is_in_brief) {
|
||||
_process_doc_line(doc_line, result.brief, space_prefix, state);
|
||||
result.brief += _process_doc_line(doc_line, result.brief, space_prefix, state);
|
||||
} else {
|
||||
_process_doc_line(doc_line, result.description, space_prefix, state);
|
||||
result.description += _process_doc_line(doc_line, result.description, space_prefix, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4832,10 +4788,10 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta
|
|||
String enum_hint_string;
|
||||
bool first = true;
|
||||
for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
if (!first) {
|
||||
enum_hint_string += ",";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
enum_hint_string += E.key.operator String().capitalize().xml_escape();
|
||||
enum_hint_string += ":";
|
||||
|
|
@ -4909,10 +4865,10 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta
|
|||
String enum_hint_string;
|
||||
bool first = true;
|
||||
for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
if (!first) {
|
||||
enum_hint_string += ",";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
enum_hint_string += E.key.operator String().capitalize().xml_escape();
|
||||
enum_hint_string += ":";
|
||||
|
|
@ -5132,14 +5088,14 @@ bool GDScriptParser::warning_ignore_annotation(AnnotationNode *p_annotation, Nod
|
|||
int end_line = p_target->end_line;
|
||||
|
||||
switch (p_target->type) {
|
||||
#define SIMPLE_CASE(m_type, m_class, m_property) \
|
||||
case m_type: { \
|
||||
#define SIMPLE_CASE(m_type, m_class, m_property) \
|
||||
case m_type: { \
|
||||
m_class *node = static_cast<m_class *>(p_target); \
|
||||
if (node->m_property == nullptr) { \
|
||||
end_line = node->start_line; \
|
||||
} else { \
|
||||
end_line = node->m_property->end_line; \
|
||||
} \
|
||||
if (node->m_property == nullptr) { \
|
||||
end_line = node->start_line; \
|
||||
} else { \
|
||||
end_line = node->m_property->end_line; \
|
||||
} \
|
||||
} break;
|
||||
|
||||
// Can contain properties (set/get).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue