Skip to content

Commit 529d7f2

Browse files
soul2zimateclaude
andauthored
fix: ensure Dockerfile analysis works in IntelliJ 2026.1 with bundled TextMate Docker grammar (#249)
* fix: improve Dockerfile parser to handle real-world Dockerfile syntax The parser was failing on common Dockerfile constructs: - Missing instructions: MAINTAINER, HEALTHCHECK, SHELL, STOPSIGNAL, ONBUILD - Line continuations with trailing whitespace after backslash - Comments inside multi-line instructions breaking continuation - ARG values containing paths (e.g., ARG HOME=/app) - Heredoc syntax (<<EOF...EOF) causing parse errors - Single-digit image tags (e.g., FROM rust:1) misidentified by lexer Add unknownLine catch-all rule so unrecognized content is silently skipped instead of causing parse errors. Reorder lexer rules so ANY_CHAR (single-char catch-all) doesn't shadow VERSION, IDENTIFIER, and IMAGE_NAME_TOKEN on same-length matches. Tested against 85+ real-world Dockerfiles across multiple frameworks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: ensure Dockerfile analysis works in IntelliJ 2026.1 with bundled TextMate Docker grammar IntelliJ 2026.1 bundles a TextMate Docker grammar that claims Dockerfile files with TextMateFileType, which implements PlainTextLikeFileType. This marker interface causes IntelliJ's DaemonCodeAnalyzer to skip ExternalAnnotator execution, preventing vulnerability analysis. Add FileTypeOverrider to force Dockerfiles to use our rhda-dockerfile file type and parser, ensuring the annotator and inspection fire correctly. Also add isDockerfile() utility for filename-based detection supporting Dockerfile, Containerfile, and their variants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * build: upgrade trustify-da-java-client to 0.0.14 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dea21cb commit 529d7f2

28 files changed

Lines changed: 866 additions & 197 deletions

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ caffeine = "3.1.8"
44
commons-compress = "1.21"
55
commons-io = "2.16.1"
66
trustify-da-api-spec = "2.0.2"
7-
trustify-da-java-client = "0.0.13"
7+
trustify-da-java-client = "0.0.14"
88
github-api = "1.314"
99
junit = "4.13.2"
1010
mockito = "4.11.0"

src/main/gen/org/jboss/tools/intellij/image/build/lexer/DockerfileLexer.java

Lines changed: 251 additions & 177 deletions
Large diffs are not rendered by default.

src/main/gen/org/jboss/tools/intellij/image/build/parser/DockerfileParser.java

Lines changed: 29 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/jboss/tools/intellij/image/build/psi/DockerfileArgValue.java

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/jboss/tools/intellij/image/build/psi/DockerfileInstructionArgs.java

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/jboss/tools/intellij/image/build/psi/DockerfileTypes.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/jboss/tools/intellij/image/build/psi/impl/DockerfileArgValueImpl.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/jboss/tools/intellij/image/build/psi/impl/DockerfileInstructionArgsImpl.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/jboss/tools/intellij/image/DockerfileAnnotator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ private static HighlightSeverity getHighlightSeverity(AnalysisReport report, Str
256256

257257
@Override
258258
public @Nullable Info collectInformation(@NotNull PsiFile file) {
259-
// Only process our custom Dockerfile type
260-
if (!DockerfileFileType.INSTANCE.equals(file.getFileType())) {
259+
// Only process Dockerfile files
260+
if (!DockerfileFileType.isDockerfile(file)) {
261261
return null;
262262
}
263263

src/main/java/org/jboss/tools/intellij/image/ImageReportAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
3737
@Override
3838
public void update(@NotNull AnActionEvent event) {
3939
var psiFile = event.getData(CommonDataKeys.PSI_FILE);
40-
if (psiFile != null && DockerfileFileType.INSTANCE.equals(psiFile.getFileType())) {
40+
if (DockerfileFileType.isDockerfile(psiFile)) {
4141
event.getPresentation().setEnabledAndVisible(true);
4242
} else {
4343
event.getPresentation().setEnabledAndVisible(false);

0 commit comments

Comments
 (0)