Working with the Program Structure Chart
The Code Insights perspective includes a program structure chart that presents the program as a collection of paragraph or procedure nodes, and rounded rectangular boxes that display the name and line number of the paragraph or procedure. These nodes are connected by lines representing the flow of data within the program, with arrowheads indicating the direction of data flow: For an input operation, such as READ or SQL FETCH, the arrowhead points from the data object to the calling object. For output operations, such as WRITE or SQL INSERT, the arrowhead points from the calling object to the data object. No arrowhead is shown if the I/O is neither clearly input or output, such an OPEN, CLOSE, or START.
Chart Characteristics
Symbols in each node indicate the type of program resource as follows:
The tab title for the program structure chart displays the program name and the characteristic indicated by the chart’s colored highlighting. Paragraph or procedure nodes in the program structure chart have different colors based on the selected metric color. Right-clicking on the chart and selecting Metric Color displays a menu of available node color choices with their corresponding program characteristics:
When nodes are colored in shades of green indicating their McCabe Complexity metric, the higher the number, the darker the shading relative to the other nodes in the chart. The darkest shading indicates the most complex parts of a given program, and the lightest indicates the least complex, even though the underlying numbers will vary for different programs.
Other metric colors are similarly lighter or darker based on the relative number of statements, blocks, conditionals, GOTOs, performs, starting lines, or SQL statements present in those paragraphs or procedure nodes. If File I/O is selected for metric color, only the paragraph or procedure nodes where file input/output occurs are colored.
Interacting with the Chart
Clicking on a node in the program structure chart selects and highlights it with a bold border around the node, while displaying the selected paragraph or procedure in the logic flow chart. Any paragraphs or procedures that call and/or are called by the selected paragraph or procedure are shown in the Callers/Callees chart, and the source is synchronized to the corresponding statement in the Workbench COBOL Editor or Workbench PL/I Editor. Ctrl+clicking one or more additional nodes selects and highlights them, while also highlighting the logical path between the selected nodes. Hovering over an execution line displays the names of the two connected nodes.
Each node in the program structure chart can be moved to a new location by dragging it with the left mouse button pressed. The contents of the entire chart can also be moved either by using the scroll bars or by placing the cursor on an open area then dragging with the left mouse button pressed.
Nodes can be arranged top to bottom (the default), left to right, or bottom to top by right-clicking anywhere in the program structure chart and selecting Layout > Top Down, Layout > Left to Right, or Layout > Bottom Up.
To make the program structure chart easier to view, the content that appears in each of the nodes can be controlled by clicking the Toggle Text toolbar button and selecting No Text, Line Number, or Full Text. If you select No Text (the default), only the symbol associated with the corresponding paragraph or procedure is shown in each node. If you select Line Number, the symbol and the source code line number are shown in each node. Select Full Text to display the symbol, the line number, and the name of the paragraph or procedure in each of the nodes.
To refresh the program structure chart from the Workbench COBOL Editor or Workbench PL/I Editor source, either click the Reanalyze Program toolbar button, or right-click the source and select Analyze Program. The program structure chart is also refreshed when you save your program.
Collapsing and Expanding Nodes
Program structure chart nodes can be collapsed to hide subsequent nodes by right-clicking and selecting Collapse. The collapsed node includes a red indicator in the lower right corner showing the number of levels that have been collapsed. To redisplay nodes hidden under a collapsed node, right-click the node and select Expand, Expand All, or Expand Levels. Selecting Expand expands the collapsed node one level. Selecting Expand All fully expands all nodes under the collapsed node. Expand Levels provides sub-menu choices to expand the collapsed node by 3, 5, or 7 levels. If the node has been collapsed more levels than it is expanded, subsequent nodes that remain collapsed include a red indicator showing the number of levels that could still be expanded. For easier viewing after the desired nodes have been collapsed, the chart can be redrawn without the hidden nodes by right-clicking anywhere in the program structure chart and selecting the desired Layout> option.
Viewing a Subsection of the Chart
Large program structure charts can be difficult to view and navigate. To make it easier to focus on a particular section of the chart, right-click the node you are interested in and select View Subgraph > Make Root. The selected node becomes the root node for a program structure sub-chart, and an indicator appears in the top right corner of the node showing how many parent nodes directly above have been hidden. A node must have children to be set as root. To display one level higher, right-click the new root node and select View Subgraph > Show Parents. To redisplay the full program structure chart, right-click anywhere in the chart and select View Subgraph > Show All Nodes.
Zooming and Spacing
Each chart in the Code Insights perspective can be zoomed in and out individually, and the spacing between nodes can be increased and decreased, independent of the zoom level. The zoom percentage drop-down at the top of the each chart includes a number of preset zooms from 5% to 400%, along with the choices Page to fit the chart fully within the view, Height to fit the chart to the height of the view, and Width to fit the chart to the width of the view. Ctrl+scroll can also be used to quickly zoom in or out through the preset zoom values. A chart can also be zoomed in small increments by Alt-clicking for larger or Shift-Alt-clicking for smaller. The default is 100%.
To view details about an individual node in full size while zoomed out smaller than 100%, simply hover over the desired node. A full-size tooltip showing the associated line of code is temporarily displayed.
The numeric spinner next to the zoom level controls the spacing between nodes, with higher numbers providing more space. Available spacing values are 0 through 50. The default is 0.
Charting of Dead Code
If "dead code" that can never be executed exists in the program, the corresponding nodes appear separated from the main portion of the program structure chart and are indicated by a and gray shading. The nodes and code blocks with dead code can be toggled between hidden and visible (the default) in both the program structure chart and the related logic flow chart at once by clicking the Hide Dead Code
toolbar button. The display of dead code in other open charts remains unaffected until one of those charts is selected. Dead code in a program structure chart is associated with code problem I006 (Unentered procedure), and dead code in a logic flow chart is associated with code problem I005 (Inexecuteable statement). See Code-Problem-Descriptions for more information.
For more information, see the following topics:
- Working-with-the-Logic-Flow-Chart
- Working-with-the-Data-Flow-Chart
- Working-with-the-Callers-Callees-Chart
- Viewing-Code-Problems