Class CallGraphCollector
- All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeListener, EK9Listener
This listener walks the AST and populates a shared CallGraph with:
- Callable registrations (functions, methods, programs, operators)
- Call edges (caller → callee relationships)
- Allocated types (for RTA filtering of polymorphic calls)
- Assertion locations (for E81007 and orphan detection)
Thread-safe: Uses a shared CallGraph with ConcurrentHashMap internals. Multiple instances can process different source files in parallel.
-
Field Summary
Fields inherited from class AbstractEK9PhaseListener
symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionCallGraphCollector(ParsedModule parsedModule, CallGraph callGraph) Create a collector for call graph information.CallGraphCollector(ParsedModule parsedModule, CallGraph callGraph, ConstructionEdges constructionEdges) Create a collector that also records the calls that always run, for the construction-recursion check. -
Method Summary
Modifier and TypeMethodDescriptionvoidA property initialiser runs in its type's_i_init, so that is the caller of whatever it calls.voidEnter a parse tree produced byEK9Parser.assertDoesNotThrowExpression().voidEnter a parse tree produced byEK9Parser.assertPanicExpression().voidEnter a parse tree produced byEK9Parser.assertStatement().voidEnter a parse tree produced byEK9Parser.assertThrowsExpression().voidEnter a parse tree produced byEK9Parser.dynamicClassDeclaration().voidEnter a parse tree produced byEK9Parser.dynamicFunctionDeclaration().voidEnter a parse tree produced byEK9Parser.expression().voidEnter a parse tree produced byEK9Parser.functionDeclaration().voidEnter a parse tree produced byEK9Parser.methodDeclaration().voidEnter a parse tree produced byEK9Parser.operatorDeclaration().voidEnter a parse tree produced byEK9Parser.serviceOperationDeclaration().voidEnter a parse tree produced byEK9Parser.tryStatementExpression().voidAn injection in a callable's body is recorded against that callable, so DI completeness can follow it from every program that reaches it.voidExit a parse tree produced byEK9Parser.aggregateProperty().voidExit a parse tree produced byEK9Parser.call().voidExit a parse tree produced byEK9Parser.classDeclaration().voidExit a parse tree produced byEK9Parser.componentDeclaration().voidExit a parse tree produced byEK9Parser.dynamicClassDeclaration().voidExit a parse tree produced byEK9Parser.dynamicFunctionDeclaration().voidExit a parse tree produced byEK9Parser.functionDeclaration().voidA function named but not called here - an argument, an assignment to a delegate - can be called through that delegate once this callable has run.voidExit a parse tree produced byEK9Parser.methodDeclaration().voidExit a parse tree produced byEK9Parser.objectAccessExpression().voidExit a parse tree produced byEK9Parser.operationCall().voidExit a parse tree produced byEK9Parser.operatorDeclaration().voidA stream stage naming a function (| map with toText) - the stream calls it, no call site does.voidExit a parse tree produced byEK9Parser.recordDeclaration().voidExit a parse tree produced byEK9Parser.serviceOperationDeclaration().void| collect as TconstructsT()where the pipeline is written - phase 3 has already required that constructor to exist and be accessible here (E07835) - with no call written in the source.Methods inherited from class ScopeStackConsistencyListener
enterApplicationDeclaration, enterBlock, enterCatchStatementExpression, enterClassDeclaration, enterComponentDeclaration, enterDynamicVariableCapture, enterFinallyStatementExpression, enterForStatementExpression, enterIfStatement, enterInstructionBlock, enterPackageBlock, enterRecordDeclaration, enterReturningParam, enterServiceDeclaration, enterSingleStatementBlock, enterStreamExpression, enterStreamStatement, enterSwitchStatementExpression, enterTernaryPart, enterTextBodyDeclaration, enterTextDeclaration, enterTraitDeclaration, enterTypeDeclaration, enterWhileStatementExpressionMethods inherited from class AbstractEK9PhaseListener
exitApplicationDeclaration, exitBlock, exitCatchStatementExpression, exitDynamicVariableCapture, exitFinallyStatementExpression, exitForStatementExpression, exitIfStatement, exitInstructionBlock, exitModuleDeclaration, exitPackageBlock, exitReturningParam, exitServiceDeclaration, exitSingleStatementBlock, exitStreamExpression, exitStreamStatement, exitSwitchStatementExpression, exitTernaryPart, exitTextBodyDeclaration, exitTextDeclaration, exitTraitDeclaration, exitTryStatementExpression, exitTypeDeclaration, exitWhileStatementExpression, getErrorListener, getParsedModule, isScopeStackEmpty, pullBlockTerminationUp, pullIfElseTerminationUp, pullSwitchCaseDefaultUp, pullTryCatchFinallyUpMethods inherited from class EK9BaseListener
enterAccessModifier, enterAggregateParts, enterAllowingOnly, enterApplicationBlock, enterArgumentParam, enterAspectDeclaration, enterAssignmentExpression, enterAssignmentStatement, enterBinaryLit, enterBinaryLiteral, enterBlockStatement, enterBooleanLit, enterBooleanLiteral, enterBytesLit, enterBytesLiteral, enterCall, enterCaseExpression, enterCaseStatement, enterCharacterLit, enterCharacterLiteral, enterClassBlock, enterColourLit, enterColourLiteral, enterCompilationUnit, enterComponentBlock, enterConstantBlock, enterConstantDeclaration, enterConstantInitialiser, enterConstrainDeclaration, enterConstrainType, enterDateLit, enterDateLiteral, enterDateTimeLit, enterDateTimeLiteral, enterDeclareArgumentParam, enterDecorationDimensionLiteral, enterDecorationResolutionLiteral, enterDefaultOperator, enterDict, enterDimensionLit, enterDirective, enterDirectivePart, enterDottedName, enterDurationLit, enterDurationLiteral, enterDynamicFunctionBody, enterElseOnlyBlock, enterEmptyBlock, enterEnumerationDeclaration, enterEveryRule, enterExcludedControlFlowStatement, enterExcludedInstantiation, enterExcludedListComprehension, enterExcludedLiteral, enterExcludedParameters, enterExpressionParam, enterExtendDeclaration, enterExtendPreamble, enterFloatingPointLit, enterFloatingPointLiteral, enterForLoop, enterForRange, enterFunctionBlock, enterHttpAccess, enterHttpVerb, enterIdentifier, enterIdentifierReference, enterIfControlBlock, enterInitValuePair, enterIntegerLit, enterIntegerLiteral, enterList, enterMillisecondLit, enterMillisecondLiteral, enterModuleBlock, enterModuleDeclaration, enterModuleSegment, enterMoneyLit, enterMoneyLiteral, enterNonIdentifierOperator, enterObjectAccess, enterObjectAccessExpression, enterObjectAccessStart, enterObjectAccessType, enterOperationCall, enterOperationDetails, enterOperator, enterParameterisedArgs, enterParameterisedDetail, enterParameterisedParams, enterParameterisedType, enterParamExpression, enterPathLit, enterPathLiteral, enterPipelinePart, enterPreFlowAndControl, enterPreFlowStatement, enterPrimary, enterPrimaryReference, enterProgramBlock, enterRange, enterRecordBlock, enterReferencesBlock, enterRegExLit, enterRegisterStatement, enterRegularExpressionLiteral, enterRequireStatement, enterReservedWord, enterResolutionLit, enterSecurityConstraint, enterServiceBlock, enterSheBang, enterStatement, enterStreamCat, enterStreamExpressionTermination, enterStreamFor, enterStreamPart, enterStreamSource, enterStreamStatementTermination, enterStringLit, enterStringLiteral, enterStringPart, enterTextBlock, enterThrowStatement, enterTimeLit, enterTimeLiteral, enterTraitBlock, enterTraitPreamble, enterTraitReference, enterTraitsList, enterTypeBlock, enterTypeDef, enterVariableDeclaration, enterVersionNumberLit, enterVersionNumberLiteral, enterWebVariableCorrelation, exitAccessModifier, exitAggregateParts, exitAllowingOnly, exitApplicationBlock, exitArgumentParam, exitAspectDeclaration, exitAssertDoesNotThrowExpression, exitAssertPanicExpression, exitAssertStatement, exitAssertThrowsExpression, exitAssignmentExpression, exitAssignmentStatement, exitBinaryLit, exitBinaryLiteral, exitBlockStatement, exitBooleanLit, exitBooleanLiteral, exitBytesLit, exitBytesLiteral, exitCaseExpression, exitCaseStatement, exitCharacterLit, exitCharacterLiteral, exitClassBlock, exitColourLit, exitColourLiteral, exitCompilationUnit, exitComponentBlock, exitConstantBlock, exitConstantDeclaration, exitConstantInitialiser, exitConstrainDeclaration, exitConstrainType, exitDateLit, exitDateLiteral, exitDateTimeLit, exitDateTimeLiteral, exitDeclareArgumentParam, exitDecorationDimensionLiteral, exitDecorationResolutionLiteral, exitDefaultOperator, exitDict, exitDimensionLit, exitDirective, exitDirectivePart, exitDottedName, exitDurationLit, exitDurationLiteral, exitDynamicFunctionBody, exitElseOnlyBlock, exitEmptyBlock, exitEnumerationDeclaration, exitEveryRule, exitExcludedControlFlowStatement, exitExcludedInstantiation, exitExcludedListComprehension, exitExcludedLiteral, exitExcludedParameters, exitExpression, exitExpressionParam, exitExtendDeclaration, exitExtendPreamble, exitFloatingPointLit, exitFloatingPointLiteral, exitForLoop, exitForRange, exitFunctionBlock, exitHttpAccess, exitHttpVerb, exitIdentifier, exitIfControlBlock, exitInitValuePair, exitIntegerLit, exitIntegerLiteral, exitList, exitMillisecondLit, exitMillisecondLiteral, exitModuleBlock, exitModuleSegment, exitMoneyLit, exitMoneyLiteral, exitNonIdentifierOperator, exitObjectAccess, exitObjectAccessStart, exitObjectAccessType, exitOperationDetails, exitOperator, exitParameterisedArgs, exitParameterisedDetail, exitParameterisedParams, exitParameterisedType, exitParamExpression, exitPathLit, exitPathLiteral, exitPreFlowAndControl, exitPreFlowStatement, exitPrimary, exitPrimaryReference, exitProgramBlock, exitRange, exitRecordBlock, exitReferencesBlock, exitRegExLit, exitRegisterStatement, exitRegularExpressionLiteral, exitRequireStatement, exitReservedWord, exitResolutionLit, exitSecurityConstraint, exitServiceBlock, exitSheBang, exitStatement, exitStreamCat, exitStreamFor, exitStreamPart, exitStreamSource, exitStreamStatementTermination, exitStringLit, exitStringLiteral, exitStringPart, exitTextBlock, exitThrowStatement, exitTimeLit, exitTimeLiteral, exitTraitBlock, exitTraitPreamble, exitTraitReference, exitTraitsList, exitTypeBlock, exitTypeDef, exitVariableDeclaration, exitVariableOnlyDeclaration, exitVersionNumberLit, exitVersionNumberLiteral, exitWebVariableCorrelation, visitErrorNode, visitTerminal
-
Constructor Details
-
CallGraphCollector
Create a collector for call graph information.- Parameters:
parsedModule- The module being processedcallGraph- Shared call graph (thread-safe)
-
CallGraphCollector
public CallGraphCollector(ParsedModule parsedModule, CallGraph callGraph, ConstructionEdges constructionEdges) Create a collector that also records the calls that always run, for the construction-recursion check.- Parameters:
parsedModule- The module being processedcallGraph- Shared call graph (thread-safe)constructionEdges- Shared store of always-run calls (thread-safe)
-
-
Method Details
-
enterMethodDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.methodDeclaration().The default implementation does nothing.
- Specified by:
enterMethodDeclarationin interfaceEK9Listener- Overrides:
enterMethodDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitMethodDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.methodDeclaration().The default implementation does nothing.
- Specified by:
exitMethodDeclarationin interfaceEK9Listener- Overrides:
exitMethodDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterFunctionDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.functionDeclaration().The default implementation does nothing.
- Specified by:
enterFunctionDeclarationin interfaceEK9Listener- Overrides:
enterFunctionDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitFunctionDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.functionDeclaration().The default implementation does nothing.
- Specified by:
exitFunctionDeclarationin interfaceEK9Listener- Overrides:
exitFunctionDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterOperatorDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.operatorDeclaration().The default implementation does nothing.
- Specified by:
enterOperatorDeclarationin interfaceEK9Listener- Overrides:
enterOperatorDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitOperatorDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.operatorDeclaration().The default implementation does nothing.
- Specified by:
exitOperatorDeclarationin interfaceEK9Listener- Overrides:
exitOperatorDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterServiceOperationDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.serviceOperationDeclaration().The default implementation does nothing.
- Specified by:
enterServiceOperationDeclarationin interfaceEK9Listener- Overrides:
enterServiceOperationDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitServiceOperationDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.serviceOperationDeclaration().The default implementation does nothing.
- Specified by:
exitServiceOperationDeclarationin interfaceEK9Listener- Overrides:
exitServiceOperationDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterDynamicFunctionDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.dynamicFunctionDeclaration().The default implementation does nothing.
- Specified by:
enterDynamicFunctionDeclarationin interfaceEK9Listener- Overrides:
enterDynamicFunctionDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitDynamicFunctionDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.dynamicFunctionDeclaration().The default implementation does nothing.
- Specified by:
exitDynamicFunctionDeclarationin interfaceEK9Listener- Overrides:
exitDynamicFunctionDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterDynamicClassDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.dynamicClassDeclaration().The default implementation does nothing.
- Specified by:
enterDynamicClassDeclarationin interfaceEK9Listener- Overrides:
enterDynamicClassDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitClassDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.classDeclaration().The default implementation does nothing.
- Specified by:
exitClassDeclarationin interfaceEK9Listener- Overrides:
exitClassDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitRecordDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.recordDeclaration().The default implementation does nothing.
- Specified by:
exitRecordDeclarationin interfaceEK9Listener- Overrides:
exitRecordDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitComponentDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.componentDeclaration().The default implementation does nothing.
- Specified by:
exitComponentDeclarationin interfaceEK9Listener- Overrides:
exitComponentDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitDynamicClassDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.dynamicClassDeclaration().The default implementation does nothing.
- Specified by:
exitDynamicClassDeclarationin interfaceEK9Listener- Overrides:
exitDynamicClassDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterAggregateProperty
A property initialiser runs in its type's_i_init, so that is the caller of whatever it calls. Without this, a top-level type's initialiser calls had no caller and were dropped, and a dynamic class's were filed under the function declaring it (front-end audit SF2).- Specified by:
enterAggregatePropertyin interfaceEK9Listener- Overrides:
enterAggregatePropertyin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitAggregateProperty
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.aggregateProperty().The default implementation does nothing.
- Specified by:
exitAggregatePropertyin interfaceEK9Listener- Overrides:
exitAggregatePropertyin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitCall
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.call().The default implementation does nothing.
- Specified by:
exitCallin interfaceEK9Listener- Overrides:
exitCallin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitOperationCall
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.operationCall().The default implementation does nothing.
- Specified by:
exitOperationCallin interfaceEK9Listener- Overrides:
exitOperationCallin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitObjectAccessExpression
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.objectAccessExpression().The default implementation does nothing.
- Specified by:
exitObjectAccessExpressionin interfaceEK9Listener- Overrides:
exitObjectAccessExpressionin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterExpression
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.expression().The default implementation does nothing.
- Specified by:
enterExpressionin interfaceEK9Listener- Overrides:
enterExpressionin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterTryStatementExpression
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.tryStatementExpression().The default implementation does nothing.
- Specified by:
enterTryStatementExpressionin interfaceEK9Listener- Overrides:
enterTryStatementExpressionin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
enterVariableOnlyDeclaration
An injection in a callable's body is recorded against that callable, so DI completeness can follow it from every program that reaches it. A PROPERTY's injection is not: it belongs to its type and is required wherever the type is constructed - which DI completeness follows through the construction - not wherever the type is declared (a dynamic class's properties sit inside the function declaring it).- Specified by:
enterVariableOnlyDeclarationin interfaceEK9Listener- Overrides:
enterVariableOnlyDeclarationin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitIdentifierReference
A function named but not called here - an argument, an assignment to a delegate - can be called through that delegate once this callable has run. Recorded as a value reference, never a call edge (seeCallGraph.getValueReferences(String)). A call's own name records one too, which adds nothing: the call edge already reaches it.- Specified by:
exitIdentifierReferencein interfaceEK9Listener- Overrides:
exitIdentifierReferencein classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitPipelinePart
A stream stage naming a function (| map with toText) - the stream calls it, no call site does.- Specified by:
exitPipelinePartin interfaceEK9Listener- Overrides:
exitPipelinePartin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitStreamExpressionTermination
| collect as TconstructsT()where the pipeline is written - phase 3 has already required that constructor to exist and be accessible here (E07835) - with no call written in the source. It is recorded as the construction it is, through the same route as a writtenT(), so dead-code and DI analysis see the constructor (and whatever it calls) as used.- Specified by:
exitStreamExpressionTerminationin interfaceEK9Listener- Overrides:
exitStreamExpressionTerminationin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterAssertStatement
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.assertStatement().The default implementation does nothing.
- Specified by:
enterAssertStatementin interfaceEK9Listener- Overrides:
enterAssertStatementin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterAssertThrowsExpression
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.assertThrowsExpression().The default implementation does nothing.
- Specified by:
enterAssertThrowsExpressionin interfaceEK9Listener- Overrides:
enterAssertThrowsExpressionin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterAssertDoesNotThrowExpression
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.assertDoesNotThrowExpression().The default implementation does nothing.
- Specified by:
enterAssertDoesNotThrowExpressionin interfaceEK9Listener- Overrides:
enterAssertDoesNotThrowExpressionin classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterAssertPanicExpression
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.assertPanicExpression().The default implementation does nothing.
- Specified by:
enterAssertPanicExpressionin interfaceEK9Listener- Overrides:
enterAssertPanicExpressionin classEK9BaseListener- Parameters:
ctx- the parse tree
-