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

PAN: handle multiline tokens better during flattening #5292

Merged
merged 5 commits into from
Dec 20, 2019
Merged

Conversation

sfraint
Copy link
Member

@sfraint sfraint commented Dec 20, 2019

During flattening, some tokens may span multiple lines (e.g. quoted strings: "something\nsomething"). Currently, when the line map is being updated, these multiline tokens are not taken into account, so mapping for any line after a multiline token is shifted and incorrect.


This PR takes into account multiline tokens when populating the line map. After this PR, all lines in the output text corresponding to the multiline token are mapped back to the original config line containing the token start.

@batfish-bot
Copy link

This change is Reviewable

Copy link
Contributor

@progwriter progwriter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sfraint)


projects/batfish/src/main/java/org/batfish/grammar/palo_alto_nested/PaloAltoNestedFlattener.java, line 112 at r1 (raw file):

      for (WordContext wordCtx : line) {
        sb.append(" ");
        int orgLine = wordCtx.WORD().getSymbol().getLine();

is there a strong reason to do this over wordCtx.getStart().getLine()? If yes, should this be documented?

Copy link
Member Author

@sfraint sfraint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @progwriter)


projects/batfish/src/main/java/org/batfish/grammar/palo_alto_nested/PaloAltoNestedFlattener.java, line 112 at r1 (raw file):

Previously, progwriter (Victor Heorhiadi) wrote…

is there a strong reason to do this over wordCtx.getStart().getLine()? If yes, should this be documented?

No, in this case they should be the same.

@codecov
Copy link

codecov bot commented Dec 20, 2019

Codecov Report

Merging #5292 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master    #5292      +/-   ##
============================================
- Coverage     73.39%   73.38%   -0.01%     
+ Complexity    31956    31954       -2     
============================================
  Files          2624     2624              
  Lines        128893   128897       +4     
  Branches      15499    15500       +1     
============================================
- Hits          94602    94596       -6     
- Misses        26802    26810       +8     
- Partials       7489     7491       +2
Impacted Files Coverage Δ Complexity Δ
...mmar/palo_alto_nested/PaloAltoNestedFlattener.java 97.1% <100%> (+0.17%) 20 <1> (+2) ⬆️
...rc/main/java/org/batfish/datamodel/flow/Trace.java 87.09% <0%> (-3.23%) 12% <0%> (-1%)
...ava/org/batfish/datamodel/bgp/Layer2VniConfig.java 80% <0%> (-2%) 13% <0%> (-1%)
...col/src/main/java/org/batfish/role/InferRoles.java 89.54% <0%> (-1.37%) 50% <0%> (-1%)
...src/main/java/org/batfish/coordinator/PoolMgr.java 64.04% <0%> (-1.13%) 15% <0%> (-1%)
...batfish/src/main/java/org/batfish/main/Driver.java 38.25% <0%> (-0.25%) 28% <0%> (ø)
...tfish/representation/cisco/CiscoConfiguration.java 85.56% <0%> (-0.13%) 523% <0%> (-1%)

Copy link
Contributor

@progwriter progwriter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@sfraint sfraint merged commit fbb03e4 into master Dec 20, 2019
@sfraint sfraint deleted the pan-linemap-fix branch December 20, 2019 21:34
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.

None yet

3 participants