Skip to content

fix(scanner): parse packages after leading comments - #45

Open
JohnXu22786 wants to merge 4 commits into
mainfrom
bug/parse-package-after-leading-directives
Open

JohnXu22786 wants to merge 4 commits into
mainfrom
bug/parse-package-after-leading-directives

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

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.

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.
@JohnXu22786 JohnXu22786 reopened this Sep 25, 2026
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.

1 participant