MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / process_class_for_fields

Function process_class_for_fields

internal/cbm/lsp/php_lsp.c:3921–4204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3919}
3920
3921static void process_class_for_fields(PHPLSPContext *ctx, CBMTypeRegistry *reg, TSNode class_node,
3922 php_class_field_table_t *tab) {
3923 const char *cqn = class_qn_for_node(ctx, class_node);
3924 if (!cqn)
3925 return;
3926 php_class_fields_t *f = fields_for(tab, cqn, ctx->arena);
3927 if (!f)
3928 return;
3929
3930 /* PHPDoc on the class itself: @property + @method tags. */
3931 char *class_doc = fetch_leading_phpdoc(ctx, class_node);
3932 if (class_doc) {
3933 apply_phpdoc_class_tags(ctx, reg, cqn, class_doc, f);
3934 }
3935
3936 /* Belt-and-suspenders: walk the class declaration's `base_clause` and
3937 * `class_interface_clause` to gather extends/implements QNs and append
3938 * them to the registered type's embedded_types. The unified extractor
3939 * is supposed to populate base_classes for class_declaration but
3940 * may miss interface_declaration's `extends Base` chain or use a
3941 * raw form (with backslashes) that doesn't round-trip cleanly.
3942 * Doing this AST extraction here keeps the LSP self-sufficient. */
3943 {
3944 const char *parent_qns[16];
3945 int parent_count = 0;
3946 uint32_t cnc = ts_node_child_count(class_node);
3947 for (uint32_t i = 0; i < cnc && parent_count < 16; i++) {
3948 TSNode c = ts_node_child(class_node, i);
3949 if (ts_node_is_null(c) || !ts_node_is_named(c))
3950 continue;
3951 const char *k = ts_node_type(c);
3952 if (strcmp(k, "base_clause") != 0 && strcmp(k, "class_interface_clause") != 0) {
3953 continue;
3954 }
3955 uint32_t bnc = ts_node_child_count(c);
3956 for (uint32_t j = 0; j < bnc && parent_count < 16; j++) {
3957 TSNode bc = ts_node_child(c, j);
3958 if (ts_node_is_null(bc) || !ts_node_is_named(bc))
3959 continue;
3960 const char *bk = ts_node_type(bc);
3961 if (strcmp(bk, "name") != 0 && strcmp(bk, "qualified_name") != 0)
3962 continue;
3963 char *t = php_node_text(ctx, bc);
3964 if (!t)
3965 continue;
3966 const char *resolved = php_resolve_class_name(ctx, t);
3967 if (!resolved)
3968 continue;
3969 parent_qns[parent_count++] = resolved;
3970 }
3971 }
3972 if (parent_count > 0) {
3973 for (int t = 0; t < reg->type_count; t++) {
3974 if (strcmp(reg->types[t].qualified_name, cqn) != 0)
3975 continue;
3976 /* Merge with existing embedded_types — dedup. */
3977 int existing = 0;
3978 if (reg->types[t].embedded_types) {

Callers 1

Calls 15

class_qn_for_nodeFunction · 0.85
fields_forFunction · 0.85
fetch_leading_phpdocFunction · 0.85
apply_phpdoc_class_tagsFunction · 0.85
php_node_textFunction · 0.85
php_resolve_class_nameFunction · 0.85
child_namedFunction · 0.85
extract_property_declFunction · 0.85
add_fieldFunction · 0.85
cbm_type_namedFunction · 0.85
process_trait_useFunction · 0.85
extract_promoted_paramFunction · 0.85

Tested by

no test coverage detected