Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improve correction of whitespace during difference application #4316

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

jlerbsc
Copy link
Collaborator

@jlerbsc jlerbsc commented Feb 8, 2024

Fixes #1638 .

Lexical preservation is based on decomposing AST nodes into tokens. Spaces, tabs and end-of-line characters are also represented in the form of tokens. When lexical preservation is enabled, each operation on the AST updates this list of tokens, which are then printed to restore the lines of code.

The list of tokens analysed is defined from the parent node of the node on which the operation is performed. In the example provided, this is the list of tokens representing the declaration of the method on which the annotation is removed.

The problem you describe arises when you try to delete the first element in the list, as the prior indentation is generally carried by the parent node of the element in consideration (in this case, the annotation). Here, the tokens representing the method declaration are not sufficient as they do not contain the indentation information because they start with the element representing the annotation. We therefore need to analyse the parent node of the method declaration, then search the list of tokens for the element corresponding to the method declaration and finally determine whether an indentation is present and delete it if necessary.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (02deca7) 51.789% compared to head (9147ce2) 51.833%.
Report is 1 commits behind head on master.

❗ Current head 9147ce2 differs from pull request most recent head df56883. Consider uploading reports for the commit df56883 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##            master     #4316       +/-   ##
=============================================
+ Coverage   51.789%   51.833%   +0.043%     
=============================================
  Files          497       497               
  Lines        28305     28335       +30     
  Branches      4901      4912       +11     
=============================================
+ Hits         14659     14687       +28     
+ Misses       11614     11609        -5     
- Partials      2032      2039        +7     
Flag Coverage Δ
AlsoSlowTests 51.833% <78.125%> (+0.043%) ⬆️
javaparser-core 51.833% <78.125%> (+0.043%) ⬆️
javaparser-symbol-solver 51.833% <78.125%> (+0.043%) ⬆️
jdk-10 51.829% <78.125%> (+0.043%) ⬆️
jdk-11 51.829% <78.125%> (+0.051%) ⬆️
jdk-12 51.829% <78.125%> (+0.051%) ⬆️
jdk-13 51.829% <78.125%> (+0.043%) ⬆️
jdk-14 51.829% <78.125%> (+0.043%) ⬆️
jdk-15 51.829% <78.125%> (+0.043%) ⬆️
jdk-16 51.829% <78.125%> (+0.043%) ⬆️
jdk-17 51.829% <78.125%> (+0.043%) ⬆️
jdk-18 51.829% <78.125%> (+0.043%) ⬆️
jdk-8 51.828% <78.125%> (+0.043%) ⬆️
jdk-9 51.829% <78.125%> (+0.043%) ⬆️
macos-latest 51.826% <78.125%> (+0.043%) ⬆️
ubuntu-latest 51.815% <78.125%> (+0.047%) ⬆️
windows-latest 51.812% <78.125%> (+0.044%) ⬆️

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

Files Coverage Δ
...lexicalpreservation/changes/ListRemovalChange.java 69.565% <66.666%> (-4.119%) ⬇️
...parser/printer/lexicalpreservation/Difference.java 76.628% <80.769%> (+0.217%) ⬆️

... and 3 files 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 a2ece74...df56883. Read the comment docs.

@jlerbsc jlerbsc merged commit 1a70725 into javaparser:master Feb 8, 2024
38 checks passed
@jlerbsc jlerbsc added this to the next release milestone Feb 8, 2024
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Fixed A PR that offers a fix or correction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Further improve correction of whitespace during difference application
1 participant