@@ -1161,6 +1161,65 @@ static char *extract_nickel_callee(CBMArena *a, TSNode node, const char *source,
11611161 return NULL ;
11621162}
11631163
1164+ // Pkl: `unqualifiedAccessExpr` / `qualifiedAccessExpr` are the same node whether
1165+ // they are a call (`helper(a)`) or a bare property read (`host`) — the only
1166+ // discriminator is an `argumentList` child, so both are gated on it. For a
1167+ // qualified call the method name is the `identifier` child that is not the
1168+ // `receiver`; the receiver is prefixed only when it is itself a plain name
1169+ // (`utils.fallback(a)` -> "utils.fallback", module-qualified, which cbm.c
1170+ // shortens to the last dotted segment when resolving). A receiver that is itself
1171+ // a call must NOT be prefixed: `s.trim().toLowerCase()` -> "toLowerCase", since
1172+ // the receiver's text carries parens and would never resolve.
1173+ // `newExpr` resolves to its `declaredType` so `new Server {}` links to the class.
1174+ static char * extract_pkl_callee (CBMArena * a , TSNode node , const char * source , const char * nk ) {
1175+ if (strcmp (nk , "newExpr" ) == 0 ) {
1176+ // `new { ... }` with an inferred type has no declaredType child.
1177+ TSNode dt = cbm_find_child_by_kind (node , "declaredType" );
1178+ return ts_node_is_null (dt ) ? NULL : cbm_node_text (a , dt , source );
1179+ }
1180+
1181+ bool qualified = strcmp (nk , "qualifiedAccessExpr" ) == 0 ;
1182+ if (!qualified && strcmp (nk , "unqualifiedAccessExpr" ) != 0 ) {
1183+ return NULL ;
1184+ }
1185+ // No argument list -> property read, not a call.
1186+ if (ts_node_is_null (cbm_find_child_by_kind (node , "argumentList" ))) {
1187+ return NULL ;
1188+ }
1189+
1190+ TSNode recv = ts_node_child_by_field_name (node , TS_FIELD ("receiver" ));
1191+ TSNode name = (TSNode ){0 };
1192+ uint32_t nc = ts_node_named_child_count (node );
1193+ for (uint32_t i = 0 ; i < nc ; i ++ ) {
1194+ TSNode child = ts_node_named_child (node , i );
1195+ if (!ts_node_is_null (recv ) && ts_node_eq (child , recv )) {
1196+ continue ;
1197+ }
1198+ if (strcmp (ts_node_type (child ), "identifier" ) == 0 ) {
1199+ name = child ;
1200+ break ;
1201+ }
1202+ }
1203+ if (ts_node_is_null (name )) {
1204+ return NULL ;
1205+ }
1206+ char * mn = cbm_node_text (a , name , source );
1207+ if (!mn || !mn [0 ]) {
1208+ return NULL ;
1209+ }
1210+ if (!qualified || ts_node_is_null (recv )) {
1211+ return mn ;
1212+ }
1213+ if (strcmp (ts_node_type (recv ), "unqualifiedAccessExpr" ) == 0 &&
1214+ ts_node_is_null (cbm_find_child_by_kind (recv , "argumentList" ))) {
1215+ char * rt = cbm_node_text (a , recv , source );
1216+ if (rt && rt [0 ]) {
1217+ return cbm_arena_sprintf (a , "%s.%s" , rt , mn );
1218+ }
1219+ }
1220+ return mn ;
1221+ }
1222+
11641223// Typst: a `call` node's callee is its `item` field (an ident), matching the
11651224// def-side resolution of `#let greet(name) = ...`.
11661225static char * extract_typst_callee (CBMArena * a , TSNode node , const char * source , const char * nk ) {
@@ -1789,6 +1848,15 @@ static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, C
17891848 }
17901849 }
17911850
1851+ /* Pkl: resolve here and return unconditionally — the access-expr call node
1852+ * types double as plain property reads, so falling through to field-based or
1853+ * generic first-identifier resolution would mint a CALLS edge for every
1854+ * property read (a bare `host` has an `identifier` first child, which the
1855+ * generic fallback would happily emit). NULL here means "not a call". */
1856+ if (lang == CBM_LANG_PKL ) {
1857+ return extract_pkl_callee (a , node , source , ts_node_type (node ));
1858+ }
1859+
17921860 // Helm / Go templates: resolve `include "x"` / `template "x"` to the
17931861 // referenced named template so it links to the define'd Function (#338).
17941862 if (lang == CBM_LANG_GOTEMPLATE ) {
0 commit comments