remove unwanted lib's
This commit is contained in:
BIN
lib/.DS_Store
vendored
BIN
lib/.DS_Store
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
49
src/CIA.java
49
src/CIA.java
@@ -4,11 +4,25 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* PDG Tool: Change Impact Analysis
|
||||
* Usage: java PDGTool <java-file> [line-number]
|
||||
* Change Impact Analysis (CIA) Tool
|
||||
*
|
||||
* This tool performs program dependence graph (PDG) analysis on Java source files
|
||||
* to identify which lines of code are impacted by changes to a specific line.
|
||||
*
|
||||
* The analysis works by:
|
||||
* 1. Building a Control Flow Graph (CFG) from the source code
|
||||
* 2. Constructing a Program Dependence Graph (PDG) with control and data dependencies
|
||||
* 3. Computing forward slices to determine impact
|
||||
*
|
||||
* Usage: java CIA <java-file> [line-number]
|
||||
*/
|
||||
public class CIA {
|
||||
|
||||
/**
|
||||
* Main entry point for the Change Impact Analysis tool.
|
||||
* Validates arguments and initiates the PDG analysis.
|
||||
*
|
||||
* @param args Command line arguments: [0] = filename, [1] = optional line number
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.err.println("Usage: java PDGTool <java-file> [line-number]");
|
||||
@@ -27,6 +41,18 @@ public class CIA {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs PDG analysis on the specified Java file.
|
||||
*
|
||||
* This method orchestrates the complete analysis workflow:
|
||||
* 1. Builds the Control Flow Graph (CFG)
|
||||
* 2. Constructs the Program Dependence Graph (PDG)
|
||||
* 3. Either displays all dependencies or computes impact for a specific line
|
||||
*
|
||||
* @param filename Path to the Java source file to analyze
|
||||
* @param targetLine Optional line number to analyze for change impact (null for all dependencies)
|
||||
* @throws IOException If file cannot be read or parsed
|
||||
*/
|
||||
private static void analyzePDG(String filename, Integer targetLine) throws IOException {
|
||||
System.out.println("PDG Analysis Tool");
|
||||
System.out.println("File: " + filename);
|
||||
@@ -59,6 +85,19 @@ public class CIA {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes and displays the change impact for a specific line of code.
|
||||
*
|
||||
* Change impact is determined by computing a forward slice from the target line,
|
||||
* which identifies all statements that could be affected by modifying the target.
|
||||
* This includes both direct dependencies (data flow) and indirect dependencies
|
||||
* (control flow).
|
||||
*
|
||||
* @param cfg The Control Flow Graph of the program
|
||||
* @param pdg The Program Dependence Graph containing dependency information
|
||||
* @param cfgBuilder The CFG builder for line number mapping
|
||||
* @param targetLine The line number to analyze for change impact
|
||||
*/
|
||||
private static void computeImpact(ControlFlowGraph cfg, PDG pdg,
|
||||
CFGBuilder cfgBuilder, int targetLine) {
|
||||
System.out.println("\n=== Impact Analysis for Line " + targetLine + " ===");
|
||||
@@ -76,7 +115,9 @@ public class CIA {
|
||||
System.out.println(" " + node.label());
|
||||
}
|
||||
|
||||
// Compute forward slice
|
||||
// Compute forward slice: all nodes reachable via dependencies
|
||||
// The forward slice represents all statements that could be affected
|
||||
// by changes to the target line
|
||||
Set<String> allImpacted = new HashSet<>();
|
||||
for (Node node : nodesAtLine) {
|
||||
Set<String> impacted = pdg.computeForwardSlice(node.label());
|
||||
|
||||
@@ -6,8 +6,11 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Simple Program Dependence Graph (PDG)
|
||||
* Computes control and data dependencies for a CFG
|
||||
* Implementation notes:
|
||||
* - Control dependencies computed via iterative reachability analysis
|
||||
* - Data dependencies computed via reaching definitions analysis
|
||||
* - Support Java 1.4 syntax with simple pattern matching
|
||||
*
|
||||
*/
|
||||
public class PDG {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user