Updated getAllLineNumbers function, was moving into cfg it returns a List<Integer>

This commit is contained in:
Nicolas Amaya
2025-12-14 16:24:46 -07:00
parent 9437b5e88d
commit c70db58e20
2 changed files with 59 additions and 44 deletions

View File

@@ -43,7 +43,7 @@ public class PDGTool {
// Step 3: Show results
System.out.println("\n=== Available Lines ===");
List<Integer> lines = cfgBuilder.getAllLineNumbers();
List<Integer> lines = cfg.getAllLineNumbers();
System.out.println("Lines with statements: " + lines);
// If specific line requested, compute impact

View File

@@ -103,6 +103,17 @@ public class ControlFlowGraph {
return Collections.unmodifiableList(result);
}
public List<Integer> getAllLineNumbers() {
List<Integer> lineNumbers = new ArrayList<>();
for (List<Node> listNodes : this.nodes.values()) {
for (Node n : listNodes) {
lineNumbers.add(n.getLineNumber());
}
}
return lineNumbers;
}
/**
* Accesses the set of edges defined on this graph.
*
@@ -186,7 +197,8 @@ public class ControlFlowGraph {
* Cannot be null or empty.
* @return The newly created edge.
* @throws IllegalArgumentException
* If the label is null or empty or either of the indicated nodes is
* If the label is null or empty or either of
* the indicated nodes is
* null.
*/
public Edge buildEdge(Node source, Node target, EdgeLabel label) {
@@ -213,14 +225,17 @@ public class ControlFlowGraph {
* @param target
* The target node. Cannot be null.
* @param label
* A label for the new edge that may be used in identifying it.
* A label for the new edge that may be used in identifying
* it.
* Cannot be null or empty.
* @param extendedLabel
* An extension to the label for the new edge that may be used in
* An extension to the label for the new edge that may be
* used in
* identifying it.
* @return The newly created edge.
* @throws IllegalArgumentException
* If the label is null or empty or either of the indicated nodes is
* If the label is null or empty or either of
* the indicated nodes is
* null.
*/
public Edge buildEdge(Node source, Node target, EdgeLabel label, String extendedLabel) {