Skip to content

feat: add function-level slicing mode (--function-slice)#44

Open
lsz-asd wants to merge 9 commits into
resess:devfrom
lsz-asd:main
Open

feat: add function-level slicing mode (--function-slice)#44
lsz-asd wants to merge 9 commits into
resess:devfrom
lsz-asd:main

Conversation

@lsz-asd

@lsz-asd lsz-asd commented May 9, 2026

Copy link
Copy Markdown

Summary

Add function-level slicing as an alternative to the existing line-level
slicing. When --function-slice (-fs) is enabled, the slicing criterion
is expanded from a single source line to all trace statements within the
containing method, producing a method-grained backward slice.

Motivation

Line-level slicing answers "which lines affect this specific statement?"
Function-level slicing answers "which methods affect this entire function?"
This is useful for understanding inter-procedural dependencies at a higher
level of abstraction.

Changes

File Change
CommandParser.java Add -fs/--function-slice CLI flag
Slicer.java Expand slicing criterion to all statements in the target method
SlicePrettyPrinter.java New — method-grouped output and DOT graph
slicer4j.py Add -fs and -tcd flags to Python wrapper

New output files (only with -fs)

  • slice-function.log — slice results grouped by method signature
  • slice-pretty.log — human-readable report with inter-method dependency graph
  • slice-graph-function.pdf — method-level DOT dependency graph

Usage

# Line-level (existing behavior, unchanged)
python3 slicer4j.py -j app.jar -o out/ -b Foo:42 -m "Foo arg1"

# Function-level (new)
python3 slicer4j.py -j app.jar -o out/ -b Foo:42 -m "Foo arg1" -fs

Test plan

  • Compiles with mvn -Dmaven.test.skip=true clean package
  • Tested on benchmarks/SliceMe — function-level slice correctly groups
    main() and parse() methods
  • Tested on benchmarks/JacksonCore_4b — function-level slice captures
    TextBuffer.expandCurrentSegment() dependencies
  • Existing test suite unaffected (no regressions)

Screenshots

image image

solomanz and others added 9 commits June 11, 2023 11:39
Add function-level slicing as an alternative to line-level slicing.
  When --function-slice (-fs) is enabled, the slicing criterion is
  expanded from a single source line to all trace statements within
  the containing method, producing a method-grained backward slice.

  Changes:
  - CommandParser: add -fs/--function-slice CLI flag
  - Slicer: expand slicing criterion to all statements in target method
  - SlicePrettyPrinter: new utility class for method-grouped output
  - slicer4j.py: add -fs and -tcd options to Python wrapper

  New output files (function-slice mode only):
  - slice-function.log: slice results grouped by method signature
  - slice-pretty.log: human-readable report with dependency graph
  - slice-graph-function.pdf: method-level DOT dependency graph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants