Skip to content

Commit

Permalink
finished transplatation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazy-Rabbit-2001 committed Oct 16, 2024
1 parent c1ac8fe commit 78d7189
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions modules/gdscript/editor/gdscript_docgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ void GDScriptDocGen::_generate_docs(GDScript *p_script, const GDP::ClassNode *p_

case GDP::ClassNode::Member::VARIABLE: {
const GDP::VariableNode *m_var = member.variable;
if (!m_var->exported && m_var->access_restriction != GDP::Node::ACCESS_RESTRICTION_PUBLIC) {
break;
}

const StringName &var_name = m_var->identifier->name;

p_script->member_lines[var_name] = m_var->start_line;
Expand Down
6 changes: 5 additions & 1 deletion modules/gdscript/gdscript_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ bool GDScriptAnalyzer::execute_access_protection(const GDScriptParser::ClassNode
return false;
}
if (member_node->access_restriction == GDScriptParser::Node::ACCESS_RESTRICTION_PROTECTED && is_from_non_derived) {
push_error(vformat(R"(Could not access external %s "%s", because it is protected by class "%s".)", is_from_non_derived ? "external" : "super", member_type, p_member.get_name(), p_super_class->fqcn), p_source);
push_error(vformat(R"(Could not access external %s "%s", because it is protected by class "%s".)", member_type, p_member.get_name(), p_super_class->fqcn), p_source);
return false;
}
}
Expand Down Expand Up @@ -4108,6 +4108,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
p_identifier->reduced_value = member.constant->initializer->reduced_value;
p_identifier->source = GDScriptParser::IdentifierNode::MEMBER_CONSTANT;
p_identifier->constant_source = member.constant;
execute_access_protection(member, parser->current_class, script_class, p_identifier);
return;
}

Expand All @@ -4133,6 +4134,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
p_identifier->source = member.variable->is_static ? GDScriptParser::IdentifierNode::STATIC_VARIABLE : GDScriptParser::IdentifierNode::MEMBER_VARIABLE;
p_identifier->variable_source = member.variable;
member.variable->usages += 1;
execute_access_protection(member, parser->current_class, script_class, p_identifier);
return;
}
} break;
Expand All @@ -4143,6 +4145,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
p_identifier->source = GDScriptParser::IdentifierNode::MEMBER_SIGNAL;
p_identifier->signal_source = member.signal;
member.signal->usages += 1;
execute_access_protection(member, parser->current_class, script_class, p_identifier);
return;
}
} break;
Expand All @@ -4153,6 +4156,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
p_identifier->source = GDScriptParser::IdentifierNode::MEMBER_FUNCTION;
p_identifier->function_source = member.function;
p_identifier->function_source_is_static = member.function->is_static;
execute_access_protection(member, parser->current_class, script_class, p_identifier);
return;
}
} break;
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4229,7 +4229,7 @@ bool GDScriptParser::access_protected_annotation(AnnotationNode *p_annotation, N

AssignableNode *member = static_cast<AssignableNode *>(p_target);
if (member->access_restriction == Node::ACCESS_RESTRICTION_PROTECTED) {
push_error(vformat(R"(@private" annotation can only be used once per private variable)"), p_annotation);
push_error(vformat(R"(@protected" annotation can only be used once per protected variable)"), p_annotation);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ class GDScriptParser {
}
bool is_derived_from(const StringName &p_super_class_name) const {
for (IdentifierNode *E : extends) {
if (identifier->name == p_super_class_name || p_super_class_name == identifier->name) {
if (E->name == p_super_class_name || p_super_class_name == E->name) {
return true;
}
}
Expand Down

0 comments on commit 78d7189

Please sign in to comment.