A field `vs` that javadoc's field search found for a reference without a * parameter list, weighed against javadoc's search for a METHOD of the name * from `start` (jr_walk). javadoc takes the field when no method is found, or * when the field's class is the method's class or below it * (JavacTrees.attributeDocReference, read in the JDK 21 source on * 2026-10-04). So the field binds only when
| 2882 | * a field outcome survives it). |
| 2883 | * *yielded: the field was not taken because of what lies outside. */ |
| 2884 | static jr_res_t jr_java_field(const jr_ctx_t *c, int start, const char *name, const jr_ref_t *r, |
| 2885 | const jr_msearch_t *vs, bool exact, bool *yielded) { |
| 2886 | const jr_index_t *ix = c->ix; |
| 2887 | int cf = vs->ent; |
| 2888 | char cf_kind = ix->ents[cf].kind; |
| 2889 | jr_walk_t w; |
| 2890 | jr_walk(c, start, name, JR_SEL_CALLABLES, r, cf, false, &w); |
| 2891 | bool field = false; |
| 2892 | int reason = CBM_DOCLINK_REASON_EXTERNAL; |
| 2893 | switch (w.kind) { |
| 2894 | case JR_WK_NONE: |
| 2895 | field = true; |
| 2896 | break; |
| 2897 | case JR_WK_FOUND: |
| 2898 | field = jr_is_or_extends(ix, cf, w.ent); |
| 2899 | if (!field && !w.passed_outside && !w.passed_gap) { |
| 2900 | return w.found.several ? jr_unres(CBM_DOCLINK_REASON_AMBIGUOUS) |
| 2901 | : jr_found_result(&w.found, exact); |
| 2902 | } |
| 2903 | break; |
| 2904 | case JR_WK_GIVEN: |
| 2905 | field = w.ent == JR_W_OBJECT || (w.ent == JR_W_ENUM && cf_kind == 'e') || |
| 2906 | (w.ent == JR_W_ANNOTATION && cf_kind == 'a') || |
| 2907 | (w.ent >= 0 && jr_is_or_extends(ix, cf, w.ent)); |
| 2908 | break; |
| 2909 | case JR_WK_OUTSIDE: |
| 2910 | break; |
| 2911 | case JR_WK_GAP: |
| 2912 | reason = CBM_DOCLINK_REASON_GRAPH_GAP; |
| 2913 | break; |
| 2914 | default: /* a Kotlin declaration (only with a list), or too many types */ |
| 2915 | reason = CBM_DOCLINK_REASON_AMBIGUOUS; |
| 2916 | break; |
| 2917 | } |
| 2918 | if (field) { |
| 2919 | return jr_found_result(&vs->found, exact); |
| 2920 | } |
| 2921 | if (w.passed_gap) { |
| 2922 | reason = CBM_DOCLINK_REASON_GRAPH_GAP; |
| 2923 | } |
| 2924 | *yielded = reason == CBM_DOCLINK_REASON_EXTERNAL; |
| 2925 | return jr_unres(reason); |
| 2926 | } |
| 2927 | |
| 2928 | /* The scope of `Type#x`: the type named and the types around it, innermost |
| 2929 | * first. javadoc's field search goes through them as it does for `#x`. */ |
no test coverage detected