Skip to content

Commit aa4775f

Browse files
committed
test(doc_links_pdf): receiver-qualified Go method nodes (#1913)
Two PDF doc-link tests named a Go method by its flat QN. With #1913 a Go method's QN carries its receiver, so the lookups found no node. The resolver is unchanged: for a Go method, rel(parent_class).name now equals the QN, so the method binds through its QN, like a member of any other language. - pdf_links_pipeline: page 1 names `server.Handler.Serve`; the edge target pkg.server.Serve becomes pkg.server.Handler.Serve. Same assertions: pdf_qn syntax, unique tier. - pdf_qn_method_through_owner, page 2: `time.Provider.Now` binds pkg.time.Provider.Now (was pkg.time.Now), syntax pdf_qn. - pdf_qn_method_through_owner, page 1: `time.Now` must not bind the method. The target moves to pkg.time.Provider.Now too. Against the old flat QN, no node exists any more, so the zero count would have passed vacuously. The page 2 assertion proves that the node exists. The ownerless-QN rule in doc_links_pdf.c stays: a templ method keeps the flat package QN while it carries parent_class (extract_defs.c only receiver-qualifies CBM_LANG_GO). Its comment no longer says that Go methods have no receiver. Signed-off-by: Martin Vogel <[email protected]>
1 parent 4e2dcd5 commit aa4775f

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎src/pipeline/doc_links_pdf.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,10 @@ static void qn_candidate(const pdfr_index_t *x, const cbm_gbuf_node_t *n, const
328328
const char *rel = rel_qn(x, n->qualified_name);
329329
char alt[PDFR_KEY_CAP];
330330
bool owned = owner_name(x, n, alt, sizeof(alt));
331-
/* A member whose QN leaves its owner out (a Go method's has no receiver)
332-
* is named through the owner: `time.Now` is package time's function,
333-
* never the method Now of a type that package time declares. */
331+
/* A member whose QN leaves its owner out (a templ method's keeps the flat
332+
* package QN; a Go method's did before index format 4) is named through
333+
* the owner: `time.Now` is package time's function, never the method Now
334+
* of a type that package time declares. */
334335
bool ownerless_qn = owned && !comp_suffix(rel, alt);
335336
bool via_rel = !ownerless_qn && comp_suffix(rel, s);
336337
bool via_alt = !via_rel && owned && strcmp(alt, rel) != 0 && comp_suffix(alt, s);

‎tests/test_doc_links_pdf.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,9 @@ TEST(pdf_links_pipeline) {
10871087
ASSERT_NOT_NULL(strstr(props, "\"line\":1"));
10881088
/* qualified names (pdf_qn) passed a second held-out audit (97 of 99
10891089
* correct, Wilson 95 % low 0.929) once a member whose QN leaves its owner
1090-
* out binds only through the owner. A Go method through its receiver: */
1091-
dm_edge(db, "docs.design.page_1", "pkg.server.Serve", props, sizeof(props), &n);
1090+
* out binds only through the owner. A Go method through its receiver
1091+
* (receiver-qualified QN since index format 4): */
1092+
dm_edge(db, "docs.design.page_1", "pkg.server.Handler.Serve", props, sizeof(props), &n);
10921093
ASSERT_EQ(n, 1);
10931094
ASSERT_NOT_NULL(strstr(props, "\"syntax\":\"pdf_qn\""));
10941095
ASSERT_NOT_NULL(strstr(props, "\"tier\":\"unique\""));
@@ -1142,10 +1143,12 @@ TEST(pdf_links_pipeline) {
11421143
PASS();
11431144
}
11441145

1145-
/* A held-out finding of the PDF audit: a Go method's QN has no receiver, so
1146+
/* A held-out finding of the PDF audit: a Go method's QN had no receiver, so
11461147
* `time.Now` (the standard library's function, in a spec) matched the method
11471148
* Now of a type that the repository's own package time declares. A method is
1148-
* named through its owner: `time.Provider.Now` still binds it. */
1149+
* named through its owner: `time.Provider.Now` still binds it. Since index
1150+
* format 4 the QN carries the receiver (pkg.time.Provider.Now), and both
1151+
* directions are checked against that node. */
11491152
TEST(pdf_qn_method_through_owner) {
11501153
cbm_doclink_test_set_ships(CBM_DOCLINK_PDF_QN, true);
11511154
char tmp[256];
@@ -1169,9 +1172,9 @@ TEST(pdf_qn_method_through_owner) {
11691172
ASSERT_EQ(dm_index(repo, db, NULL), 0);
11701173
char props[512];
11711174
int n;
1172-
dm_edge(db, "docs.spec.page_1", "pkg.time.Now", props, sizeof(props), &n);
1175+
dm_edge(db, "docs.spec.page_1", "pkg.time.Provider.Now", props, sizeof(props), &n);
11731176
ASSERT_EQ(n, 0);
1174-
dm_edge(db, "docs.spec.page_2", "pkg.time.Now", props, sizeof(props), &n);
1177+
dm_edge(db, "docs.spec.page_2", "pkg.time.Provider.Now", props, sizeof(props), &n);
11751178
ASSERT_EQ(n, 1);
11761179
ASSERT_NOT_NULL(strstr(props, "\"syntax\":\"pdf_qn\""));
11771180
th_cleanup(tmp);

0 commit comments

Comments
 (0)