]> Repositorios git - classgraph.git/commitdiff
Don't draw the superclass class node when an instance matches locally
authorJavier Sagredo <[email protected]>
Wed, 6 May 2026 22:11:33 +0000 (00:11 +0200)
committerJavier Sagredo <[email protected]>
Wed, 6 May 2026 23:51:06 +0000 (01:51 +0200)
Previously every "superclass needed" arrow pulled in both the matched
instance node *and* a class node for the superclass — joined to the
matched instance by an extra "defines" edge. The class node duplicated
information already on the matched-instance label, just adding clutter.
Restrict the class-node side to the no-local-match branch, which still
needs somewhere for its needs-external edge to terminate.

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

index 85fd532286ce0d30660e4276b23a94e107b52352..2ea384eba37d34ab427043180061407908c0b140 100644 (file)
         // Direct-match path uses the reduced args as before.
         const reqArgs = subbedArgs.map(reduceTypeArg);
         const matched = findMatchingInstances(sc.seSuperclass, reqArgs);
-        const scClsId = ensureClassNode(sc.seSuperclass);
         const reqLabel = 'superclass needed ' + sc.seSuperclass.qnName + ' ' +
           renderArgsCompact(reqArgs, inst.iiTyVars);
 
         if (matched.length === 0) {
-          // No instance found in our data; link to the class node and mark
-          // it as external/unresolved.
+          // No instance found in our data; link to the superclass class
+          // node (which we have to draw in this branch) and mark it
+          // external/unresolved.
+          const scClsId = ensureClassNode(sc.seSuperclass);
           els.push({ group: 'edges', data: {
             id: instId + '#sc#' + si + '#none',
             source: instId,
             label: reqLabel + '  (no local match)',
           }});
         } else {
+          // Local match(es) exist. Connect the focused instance directly
+          // to each matched instance — we deliberately *don't* also pull
+          // the superclass class node into the graph, because the same
+          // information ("instance of class Foo") is already implied by
+          // the matched instance's own label and is plainly noisy.
           for (const m of matched) {
             const mId = ensureInstanceNode(
               m, sc.seSuperclass,
               'inst:' + m._idx
             );
-            // Also draw the matched instance under its class.
-            ensureClassNode(sc.seSuperclass);
-            const linkId = scClsId + '=>' + mId;
-            if (!seenNodes.has(linkId)) {
-              seenNodes.add(linkId);
-              els.push({ group: 'edges', data: {
-                id: linkId, source: scClsId, target: mId, kind: 'defines',
-              }});
-            }
             els.push({ group: 'edges', data: {
               id: instId + '#sc#' + si + '#' + m._idx,
               source: instId,