fix(scanner): parse packages after leading comments - #45
Open
JohnXu22786 wants to merge 4 commits into
Open
JohnXu22786 wants to merge 4 commits into
JohnXu22786 wants to merge 4 commits into
Conversation
Package declarations may follow build tags and comments, so anchoring the lookup to the start of the file caused Go and Java files to fall back to path-based module IDs. Preserve line structure while ignoring comment contents before matching the declaration.
Normalize CR-only input so multiline matching sees Java declarations after comments, and mask literals before searching so package-like text blocks do not change default-package module IDs.
Package declarations can span line endings and comments, and literals must not be treated as source. Record the scanner version in incremental metadata so existing indexes are refreshed when scanner output changes.
Java permits package annotations and form-feed whitespace before the package token. Accept those legal forms while keeping package-like text inside literals from changing module IDs, and bump the scanner version so existing indexes are refreshed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does
Before this PR:
Go and Java package declarations after legal comments or build tags could be missed, package-like text inside literals could be misidentified, existing indexes did not know scanner output had changed, and legal Java package annotations/form-feed whitespace were unsupported.
After this PR:
Package detection handles CR, CRLF, and LF input, whitespace/comments between package tokens, Java package annotations, and statement boundaries. Comments and literals—including escaped Java text-block delimiters—are masked before matching. A scanner version is stored in scan configuration and bumped with scanner behavior changes so older indexes reprocess unchanged files. Regression coverage exercises these cases.
Type of change
fix
Breaking changes (if any)
None.