Modules/businessdev.ALbuild.Apps/Public/Get-BcCallGraphInfo.ps1
|
function Get-BcCallGraphInfo { <# .SYNOPSIS Looks things up in a call graph: an overview, a search, the details of one node, or a path between two. .DESCRIPTION Made for agents (and people) who need to know where something is before they read code: -Overview the parts with their summaries and sizes and the strongest connections between them -Find <words> parts, objects and methods whose name (or description) contains all the words -Show <id> a part id, an object ('Codeunit My Mgt' or 'Codeunit 50100') or a method ('Codeunit My Mgt.DoIt'): description, part, members, what it uses and what uses it -From/-To the shortest call path between two objects or parts The parts come from callgraph.architecture.json, otherwise from the folders. Pure lookups in the graph file: no AL Tool and no container are needed. .PARAMETER GraphPath The call graph folder written by New-BcCallGraph. .PARAMETER Overview Return the overview. .PARAMETER Find Words to search for. .PARAMETER Kind Limit -Find to part, object or member. .PARAMETER Limit Maximum results for -Find. Default 15. .PARAMETER Show The node to describe. .PARAMETER From Start of a path (object or part). .PARAMETER To End of a path (object or part). .PARAMETER ArchitecturePath The architecture file. Default: callgraph.architecture.json in the workspace root. .EXAMPLE Get-BcCallGraphInfo -GraphPath .albuild/callgraph -Find 'ebics order' .EXAMPLE Get-BcCallGraphInfo -GraphPath .albuild/callgraph -From 'Page bdev.BNK Bank Access' -To 'Codeunit bdev.BNK API Client' .OUTPUTS PSCustomObject (overview, show, path) or PSCustomObject[] (find). #> [CmdletBinding(DefaultParameterSetName = 'Overview')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Overview', Justification = 'Selects the parameter set.')] param( [Parameter(Mandatory)] [string] $GraphPath, [Parameter(ParameterSetName = 'Overview')] [switch] $Overview, [Parameter(Mandatory, ParameterSetName = 'Find')] [string] $Find, [Parameter(ParameterSetName = 'Find')] [ValidateSet('', 'part', 'object', 'member')] [string] $Kind = '', [Parameter(ParameterSetName = 'Find')] [ValidateRange(1, 500)] [int] $Limit = 15, [Parameter(Mandatory, ParameterSetName = 'Show')] [string] $Show, [Parameter(Mandatory, ParameterSetName = 'Path')] [string] $From, [Parameter(Mandatory, ParameterSetName = 'Path')] [string] $To, [string] $ArchitecturePath ) $context = Get-BcCallGraphContext -GraphPath $GraphPath -ArchitecturePath $ArchitecturePath $w = [ALbuild.CallGraph.Analyzer]::Open($context.Graph.GraphPath, $context.Apps, $context.WorkspaceRoot, $context.ArchitecturePath) switch ($PSCmdlet.ParameterSetName) { 'Find' { foreach ($hit in $w.Explorer.Find($Find, $Kind, $Limit)) { ConvertTo-BcCallGraphObject $hit }; return } 'Show' { $r = $w.Explorer.Show($Show) if ($null -eq $r) { throw "NOT_FOUND: '$Show' is neither a part, an object nor a method in the call graph. Search for it with 'albuild graph find' (Get-BcCallGraphInfo -Find)." } return ConvertTo-BcCallGraphObject $r } 'Path' { return ConvertTo-BcCallGraphObject $w.Explorer.Path($From, $To) } default { return ConvertTo-BcCallGraphObject $w.Explorer.Overview() } } } |