mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +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_node(p, Field, param);
|
||||||
Ast *type_expr = p->type;
|
Ast *type_expr = p->type;
|
||||||
Type *type = nullptr;
|
Type *type = nullptr;
|
||||||
|
CommentGroup *docs = p->docs;
|
||||||
|
CommentGroup *comment = p->comment;
|
||||||
|
|
||||||
if (type_expr != nullptr) {
|
if (type_expr != nullptr) {
|
||||||
type = check_type_expr(ctx, 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);
|
Entity *field = alloc_entity_field(ctx->scope, name_token, type, is_using, field_src_index);
|
||||||
add_entity(ctx, ctx->scope, name, field);
|
add_entity(ctx, ctx->scope, name, field);
|
||||||
field->Variable.field_group_index = field_group_index;
|
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);
|
array_add(&fields_array, field);
|
||||||
String tag = p->tag.string;
|
String tag = p->tag.string;
|
||||||
if (tag.len != 0 && !unquote_string(permanent_allocator(), &tag, 0, tag.text[0] == '`')) {
|
if (tag.len != 0 && !unquote_string(permanent_allocator(), &tag, 0, tag.text[0] == '`')) {
|
||||||
|
|||||||
+2
-2
@@ -185,8 +185,8 @@ struct OdinDocEntity {
|
|||||||
OdinDocTypeIndex type;
|
OdinDocTypeIndex type;
|
||||||
OdinDocString init_string;
|
OdinDocString init_string;
|
||||||
u32 reserved_for_init;
|
u32 reserved_for_init;
|
||||||
OdinDocString comment;
|
OdinDocString comment; // line comment
|
||||||
OdinDocString docs;
|
OdinDocString docs; // preceding comment
|
||||||
i32 field_group_index;
|
i32 field_group_index;
|
||||||
OdinDocEntityIndex foreign_library;
|
OdinDocEntityIndex foreign_library;
|
||||||
OdinDocString link_name;
|
OdinDocString link_name;
|
||||||
|
|||||||
@@ -811,6 +811,12 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
|||||||
comment = e->decl_info->comment;
|
comment = e->decl_info->comment;
|
||||||
docs = e->decl_info->docs;
|
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 = {};
|
String link_name = {};
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ struct Entity {
|
|||||||
String link_name;
|
String link_name;
|
||||||
String link_prefix;
|
String link_prefix;
|
||||||
String link_section;
|
String link_section;
|
||||||
|
CommentGroup *docs;
|
||||||
|
CommentGroup *comment;
|
||||||
bool is_foreign;
|
bool is_foreign;
|
||||||
bool is_export;
|
bool is_export;
|
||||||
} Variable;
|
} Variable;
|
||||||
|
|||||||
+1
-1
@@ -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.default_value = default_value;
|
||||||
result->Field.flags = flags;
|
result->Field.flags = flags;
|
||||||
result->Field.tag = tag;
|
result->Field.tag = tag;
|
||||||
result->Field.docs = docs;
|
result->Field.docs = docs;
|
||||||
result->Field.comment = comment;
|
result->Field.comment = comment;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user