Skip to content

refactor(lexicalpreservation): introduce TextElementSequence API and migrate core classes#4955

Merged
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:lpp_refactor_index_management
Jan 20, 2026
Merged

refactor(lexicalpreservation): introduce TextElementSequence API and migrate core classes#4955
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:lpp_refactor_index_management

Conversation

@jlerbsc

@jlerbsc jlerbsc commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator
  • Create TextElementSequence interface with specialized search/filtering operations (findFirst, findLast, takeWhile, anyMatch, allMatch, noneMatch)
  • Implement TextElementList with optimized index-based operations and method chaining support
  • Introduce TextElementIterator for bidirectional traversal with currentIndex() tracking
  • Replace IndexTrackingIterator with generic implementation, removing ArrayIterator
  • Migrate Difference.java: refactor processIndentation(), posOfNextComment(), removeElements() (-96 lines, ~8% reduction)
  • Migrate NodeText.java to use TextElementList internally (code simplification, -16% logic, -25% complexity)
  • Add factory method TextElementList.of(List) for fluent API chaining
  • Distinguish toList() (unmodifiable) from toMutableList() (mutable) for clear intent
  • Fix indentation preservation bugs and iterator edge cases

@codecov

codecov Bot commented Jan 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.39306% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.574%. Comparing base (b785eee) to head (a7fe71a).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...vaparser/printer/lexicalpreservation/NodeText.java 31.818% 15 Missing ⚠️
...ter/lexicalpreservation/IndexTrackingIterator.java 72.000% 7 Missing ⚠️
...r/printer/lexicalpreservation/TextElementList.java 96.250% 1 Missing and 2 partials ⚠️
...parser/printer/lexicalpreservation/Difference.java 90.000% 0 Missing and 1 partial ⚠️
...alpreservation/ReshuffledDiffElementExtractor.java 85.714% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #4955       +/-   ##
===============================================
+ Coverage     58.459%   58.574%   +0.114%     
  Complexity      2564      2564               
===============================================
  Files            692       696        +4     
  Lines          39891     39980       +89     
  Branches        7261      7274       +13     
===============================================
+ Hits           23320     23418       +98     
+ Misses         13619     13611        -8     
+ Partials        2952      2951        -1     
Flag Coverage Δ
AlsoSlowTests 58.574% <84.393%> (+0.114%) ⬆️
javaparser-core 58.574% <84.393%> (+0.114%) ⬆️
javaparser-symbol-solver 58.574% <84.393%> (+0.114%) ⬆️
jdk-10 58.144% <84.393%> (+0.115%) ⬆️
jdk-11 58.143% <84.393%> (+0.115%) ⬆️
jdk-12 58.143% <84.393%> (+0.115%) ⬆️
jdk-13 58.140% <84.393%> (+0.113%) ⬆️
jdk-14 58.376% <84.393%> (+0.115%) ⬆️
jdk-15 58.376% <84.393%> (+0.115%) ⬆️
jdk-16 58.348% <84.393%> (+0.112%) ⬆️
jdk-17 58.501% <84.393%> (+0.115%) ⬆️
jdk-18 58.501% <84.393%> (+0.115%) ⬆️
jdk-8 57.976% <84.393%> (+0.113%) ⬆️
jdk-9 58.141% <84.393%> (+0.118%) ⬆️
macos-latest 58.566% <84.393%> (+0.115%) ⬆️
ubuntu-latest 58.561% <84.393%> (+0.115%) ⬆️
windows-latest 58.556% <84.393%> (+0.115%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...inter/lexicalpreservation/TextElementIterator.java 100.000% <100.000%> (ø)
...inter/lexicalpreservation/TextElementSequence.java 100.000% <100.000%> (ø)
...parser/printer/lexicalpreservation/Difference.java 79.174% <90.000%> (+1.437%) ⬆️
...alpreservation/ReshuffledDiffElementExtractor.java 95.035% <85.714%> (ø)
...r/printer/lexicalpreservation/TextElementList.java 96.250% <96.250%> (ø)
...ter/lexicalpreservation/IndexTrackingIterator.java 72.000% <72.000%> (ø)
...vaparser/printer/lexicalpreservation/NodeText.java 50.909% <31.818%> (-1.550%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2101930...a7fe71a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlerbsc jlerbsc merged commit 05e4ee0 into javaparser:master Jan 20, 2026
34 of 35 checks passed
@jlerbsc jlerbsc added this to the next release milestone Jan 20, 2026
@jlerbsc jlerbsc added the PR: Changed A PR that changes implementation without changing behaviour (e.g. performance) label Jan 20, 2026
@jlerbsc jlerbsc deleted the lpp_refactor_index_management branch January 20, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Changed A PR that changes implementation without changing behaviour (e.g. performance)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant