CxxPreprocessor: unitilize com.sonar.sslr.api.Preprocessor::init() #1660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
the check, if CxxPreprocessor was about to start preprocessing
a new file, was previously done in CxxPreprocessor::process()
Preprocessor::process() is called multiple time per file
in the worst case it's called for each Token
there is a special initialization method Preprocessor:init(),
which is called once per file.
See com.sonar.sslr.impl.Lexer::lex(Reader reader)
override this method and put the is-new-file logic to
CxxPreprocessor::init()
we don't break any logic
we still rely on the current context file, which is set in the
proper order
context file
benefits: skip redundant checks, split the code in the more logical way
This change is