]> Repositorios git - classgraph.git/commitdiff
Show constructor names in family-view data fam-instance rows too
authorJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:43:54 +0000 (02:43 +0200)
committerJavier Sagredo <[email protected]>
Thu, 7 May 2026 00:43:54 +0000 (02:43 +0200)
The family view (drilling into a family directly) had its own
fam-instance label code path that bypassed renderFamInstHead, so
data fam-instance rows showed only their args (no constructor
names). Mirror the renderFamInstHead behaviour: append `= ConA |
ConB` for data fam-instances. The family name itself stays implicit
(it's already at the top of the family view).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
data/viewer.js

index 5cc7e36273ec3492b12067af5ec42c228ee49c80..362c98cec3f9bd2130828bab9d776c5b5c3d123e 100644 (file)
       const fiNodeId = 'faminst:' + fi._idx;
       seenNodes.add(fiNodeId);
       const args = renderArgsCompact(fi.fiArgs, fi.fiTyVars);
-      const label = fi.fiIsData
-        ? (args || '<no args>')
-        : args + ' = ' + renderArg(fi.fiRhs, fi.fiTyVars);
+      const lhs = args || '<no args>';
+      let label;
+      if (fi.fiIsData) {
+        // In the family view the family name is already shown at the
+        // top of the graph, so each row only needs `args = Cons`. We
+        // *do* want the constructor names here, the same way the
+        // instance view's renderFamInstHead does — just don't repeat
+        // the family name.
+        const dcs = fi.fiDataCons || [];
+        const cons = dcs.map(dc => dc.dcName || '?').join(' | ');
+        label = cons ? lhs + ' = ' + cons : lhs;
+      } else {
+        label = lhs + ' = ' + renderArg(fi.fiRhs, fi.fiTyVars);
+      }
       els.push({ group: 'nodes', data: {
         id: fiNodeId,
         label,