mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-22 22:35:19 +00:00
Update CommentGroup parsing for struct types
This commit is contained in:
@@ -120,6 +120,8 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entity *> *fields
|
||||
ast_node(p, Field, param);
|
||||
Ast *type_expr = p->type;
|
||||
Type *type = nullptr;
|
||||
CommentGroup *docs = p->docs;
|
||||
CommentGroup *comment = p->comment;
|
||||
|
||||
if (type_expr != nullptr) {
|
||||
type = check_type_expr(ctx, type_expr, nullptr);
|
||||
@@ -156,6 +158,14 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entity *> *fields
|
||||
Entity *field = alloc_entity_field(ctx->scope, name_token, type, is_using, field_src_index);
|
||||
add_entity(ctx, ctx->scope, name, field);
|
||||
field->Variable.field_group_index = field_group_index;
|
||||
|
||||
if (j == 0) {
|
||||
field->Variable.docs = docs;
|
||||
}
|
||||
if (j+1 == p->names.count) {
|
||||
field->Variable.comment = comment;
|
||||
}
|
||||
|
||||
array_add(&fields_array, field);
|
||||
String tag = p->tag.string;
|
||||
if (tag.len != 0 && !unquote_string(permanent_allocator(), &tag, 0, tag.text[0] == '`')) {
|
||||
|
||||
@@ -185,8 +185,8 @@ struct OdinDocEntity {
|
||||
OdinDocTypeIndex type;
|
||||
OdinDocString init_string;
|
||||
u32 reserved_for_init;
|
||||
OdinDocString comment;
|
||||
OdinDocString docs;
|
||||
OdinDocString comment; // line comment
|
||||
OdinDocString docs; // preceding comment
|
||||
i32 field_group_index;
|
||||
OdinDocEntityIndex foreign_library;
|
||||
OdinDocString link_name;
|
||||
|
||||
@@ -811,6 +811,12 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
comment = e->decl_info->comment;
|
||||
docs = e->decl_info->docs;
|
||||
}
|
||||
if (!comment && e->kind == Entity_Variable) {
|
||||
comment = e->Variable.comment;
|
||||
}
|
||||
if (!docs && e->kind == Entity_Variable) {
|
||||
docs = e->Variable.docs;
|
||||
}
|
||||
|
||||
String link_name = {};
|
||||
|
||||
|
||||
@@ -175,6 +175,8 @@ struct Entity {
|
||||
String link_name;
|
||||
String link_prefix;
|
||||
String link_section;
|
||||
CommentGroup *docs;
|
||||
CommentGroup *comment;
|
||||
bool is_foreign;
|
||||
bool is_export;
|
||||
} Variable;
|
||||
|
||||
@@ -944,7 +944,7 @@ Ast *ast_field(AstFile *f, Array<Ast *> const &names, Ast *type, Ast *default_va
|
||||
result->Field.default_value = default_value;
|
||||
result->Field.flags = flags;
|
||||
result->Field.tag = tag;
|
||||
result->Field.docs = docs;
|
||||
result->Field.docs = docs;
|
||||
result->Field.comment = comment;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user