@@ -579,7 +579,31 @@ module API {
579579 * Gets a textual representation of this node.
580580 */
581581 string toString ( ) {
582- none ( ) // defined in subclasses
582+ this = Impl:: MkRoot ( ) and result = "root"
583+ or
584+ exists ( string m | this = Impl:: MkModuleDef ( m ) | result = "module def " + m )
585+ or
586+ exists ( string m | this = Impl:: MkModuleUse ( m ) | result = "module use " + m )
587+ or
588+ exists ( string m | this = Impl:: MkModuleExport ( m ) | result = "module export " + m )
589+ or
590+ exists ( string m | this = Impl:: MkModuleImport ( m ) | result = "module import " + m )
591+ or
592+ exists ( string m , string e | this = Impl:: MkTypeUse ( m , e ) |
593+ result = "type use " + m + "::" + e
594+ )
595+ or
596+ exists ( DataFlow:: SourceNode cls | this = Impl:: MkClassInstance ( cls ) |
597+ result = "instance of " + cls .toString ( )
598+ )
599+ or
600+ exists ( DataFlow:: Node nd | this = Impl:: MkDef ( nd ) | result = "def " + nd .toString ( ) )
601+ or
602+ exists ( DataFlow:: Node nd | this = Impl:: MkUse ( nd ) | result = "use " + nd .toString ( ) )
603+ or
604+ exists ( DataFlow:: InvokeNode nd | this = Impl:: MkSyntheticCallbackArg ( nd ) |
605+ result = "callback arg " + nd .toString ( )
606+ )
583607 }
584608
585609 /**
@@ -606,25 +630,18 @@ module API {
606630 int getDepth ( ) { result = Impl:: distanceFromRoot ( this ) }
607631 }
608632
609- /** The root node of an API graph. */
610- class Root extends Node , Impl:: MkRoot {
611- override string toString ( ) { result = "root" }
612- }
633+ private predicate missingToString ( Node node ) { not exists ( node .toString ( ) ) }
613634
614- /** A node corresponding to a definition of an API component. */
615- class Definition extends Node , Impl :: TDef {
616- override string toString ( ) { result = "def " + this . getInducingNode ( ) . toString ( ) }
617- }
635+ private predicate ambiguousToString ( Node node ) { strictcount ( node . toString ( ) ) > 1 }
636+
637+ /** The root node of an API graph. */
638+ class Root extends Node , Impl :: MkRoot { }
618639
619640 /** A node corresponding to a definition of an API component. */
620- class ClassInstanceNode extends Definition , Impl:: MkClassInstance {
621- override string toString ( ) { result = "instance of " + this .getInducingNode ( ) .toString ( ) }
622- }
641+ class Definition extends Node , Impl:: TDef { }
623642
624643 /** A node corresponding to the use of an API component. */
625- class Use extends Node , Impl:: TUse {
626- override string toString ( ) { result = "use " + this .getInducingNode ( ) .toString ( ) }
627- }
644+ class Use extends Node , Impl:: TUse { }
628645
629646 /** Gets the root node. */
630647 Root root ( ) { any ( ) }
0 commit comments