A Javadoc member reference. `type` is the type it names, or JR_NONE for * `#member`, which starts at the type of the documented definition. * - a METHOD is javadoc's search (jr_walk): the first method it finds is the * one; a type outside the repository on the way, or a method the language * gives, ends it as external; a parameter list selects the overloads with * that signature
| 2952 | * - {@value} names a field and nothing else; for `Type#x` it searches the |
| 2953 | * type and its supertypes only, as before */ |
| 2954 | static jr_res_t jr_java_member(const jr_ctx_t *c, const char *name, const jr_ref_t *r, int type, |
| 2955 | bool params, bool exact, bool values_only) { |
| 2956 | const jr_index_t *ix = c->ix; |
| 2957 | bool in_scope = type == JR_NONE; |
| 2958 | int base = in_scope ? (c->nchain > 0 ? c->chain[0] : JR_NONE) : type; |
| 2959 | if (base == JR_NONE) { |
| 2960 | return jr_unres(CBM_DOCLINK_REASON_MISSING); /* no type to be a member of */ |
| 2961 | } |
| 2962 | if (!values_only && strcmp(name, ix->ents[base].name) == 0) { |
| 2963 | return jr_java_ctor(c, base, r, exact); |
| 2964 | } |
| 2965 | int sel = JR_SEL_CALLABLES | (params ? JR_SEL_SIG : 0); |
| 2966 | jr_walk_t mw; /* the method, as javadoc searches for it */ |
| 2967 | memset(&mw, 0, sizeof(mw)); |
| 2968 | mw.ent = JR_NONE; |
| 2969 | if (params) { |
| 2970 | jr_walk(c, base, name, sel, r, JR_NONE, false, &mw); |
| 2971 | return jr_java_method(c, base, name, sel, r, &mw, NULL, exact); |
| 2972 | } |
| 2973 | jr_ctx_t named; |
| 2974 | const jr_ctx_t *fc = c; /* the chain the field is searched through */ |
| 2975 | if (!in_scope && !values_only) { |
| 2976 | jr_ctx_named(&named, c, base); |
| 2977 | fc = &named; |
| 2978 | } |
| 2979 | bool chain = in_scope || !values_only; |
| 2980 | jr_msearch_t vs; |
| 2981 | int vlevel = 0; |
| 2982 | if (chain) { |
| 2983 | jr_fields_around(fc, name, &vs, &vlevel); |
| 2984 | } else { |
| 2985 | jr_fields_in(c, base, name, &vs); |
| 2986 | } |
| 2987 | if (vs.ent != JR_NONE) { |
| 2988 | for (int j = vlevel + SKIP_ONE; |
| 2989 | chain && vs.ent != fc->chain[vlevel] && !vs.clash && j < fc->nchain; j++) { |
| 2990 | jr_msearch_t outer; |
| 2991 | jr_fields_in(fc, fc->chain[j], name, &outer); |
| 2992 | vs.clash = outer.ent != JR_NONE || outer.gap; |
| 2993 | } |
| 2994 | if (vs.clash) { |
| 2995 | return jr_unres(CBM_DOCLINK_REASON_AMBIGUOUS); |
| 2996 | } |
| 2997 | if (values_only) { |
| 2998 | return jr_found_result(&vs.found, exact); |
| 2999 | } |
| 3000 | bool yielded = false; |
| 3001 | jr_res_t res = jr_java_field(c, base, name, r, &vs, exact, &yielded); |
| 3002 | if (yielded) { |
| 3003 | atomic_fetch_add(in_scope ? &ix->stats->java_field : &ix->stats->java_field_named, 1); |
| 3004 | } |
| 3005 | return res; |
| 3006 | } |
| 3007 | if (vs.gap) { |
| 3008 | return jr_unres(CBM_DOCLINK_REASON_GRAPH_GAP); /* a hidden field would come first */ |
| 3009 | } |
| 3010 | if (!values_only) { |
| 3011 | jr_walk(c, base, name, sel, r, JR_NONE, false, &mw); |
no test coverage detected