Fixing compilation after changes in platform. Localizing and refactoring#12
Conversation
|
@claude review pr with inline comments |
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 6m 42s —— View job PR Review — Localization & API migration
I left 5 inline comments on the specific lines (with one-click OverviewThis is overwhelmingly a mechanical pass: reindentation (2→4 spaces, Findings (see inline comments)🔶 Lost 🔶 🔹 🔹 Nit — Minor observations (not blocking, no inline comment)
None of these are blockers — the two 🔶 items are worth a look before merge since they're the only places behavior could actually differ from the pre-migration code. |
| Application.get().runReadAction(() -> { | ||
| if (myFile != null) { | ||
| FilePosition position = | ||
| new FilePosition(new File(Objects.requireNonNull(myFile.getCanonicalPath())), myRow - 1, myColumn); |
There was a problem hiding this comment.
Default position values depend on position() being called. myRow defaults to 0, so if the parser never calls position(...) this builds a FilePosition with myRow - 1 == -1. The old message(...) always received lineNum/columnNum directly, so it never produced a negative row. Worth confirming the platform always calls position(...) before add() for javac messages — otherwise guard against the negative row here.
| public CompileContext.MessageBuilder url(String url) { | ||
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | ||
| return this; | ||
| } |
There was a problem hiding this comment.
Same null-guard regression as in OutputParser. The old message() did url == null ? null : findFileByUrl(url). Here url() calls it unconditionally, risking an NPE if .url(null) is ever called, and the lookup now runs outside the runReadAction that wraps add():
| public CompileContext.MessageBuilder url(String url) { | |
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } | |
| public CompileContext.MessageBuilder url(String url) { | |
| myFile = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } |
| public CompileContext.MessageBuilder url(String url) { | ||
| myUrl = url; | ||
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | ||
| return this; | ||
| } |
There was a problem hiding this comment.
Possible NPE / lost null-guard. The previous message() guarded the URL with url == null ? null : findFileByUrl(url). The new builder calls findFileByUrl(url) unconditionally, so if the platform ever invokes .url(null) this will NPE. Restoring the guard keeps the old contract:
| public CompileContext.MessageBuilder url(String url) { | |
| myUrl = url; | |
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } | |
| public CompileContext.MessageBuilder url(String url) { | |
| myUrl = url; | |
| myFile = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } |
Separately: this VFS lookup used to run inside runReadAction (now moved into add()). findFileByUrl is generally expected to run under a read lock — consider deferring the lookup into the add() read action instead of doing it here.
| MessageEvent.Kind kind = switch (category) { | ||
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | ||
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | ||
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | ||
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | ||
| }; |
There was a problem hiding this comment.
This switch has no default, unlike the one in OutputParser. The old convertCategory fell back to INFO for any unrecognized category, and switch on a null category throws NPE. A defensive default restores the old behavior and avoids a MatchException if a new CompilerMessageCategory constant is ever added:
| MessageEvent.Kind kind = switch (category) { | |
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | |
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | |
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | |
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | |
| }; | |
| MessageEvent.Kind kind = switch (category) { | |
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | |
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | |
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | |
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | |
| default -> MessageEvent.Kind.INFO; | |
| }; |
| checkCancelTask.cancel(); | ||
| parser.setStopped(true); | ||
| LocalizeValue title = ApacheAntImplLocalize.antBuildLocalHistoryLabel(buildFile.getName()); | ||
| LocalizeValue buildFileName = LocalizeValue.ofNullable(buildFile.getName()); |
There was a problem hiding this comment.
Nit: buildFile.getName() is effectively non-null, so LocalizeValue.of(...) reads more accurately than ofNullable(...) here. Not a correctness issue — ofNullable is just a slightly weaker contract than what the value actually guarantees.
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 5m 47s —— View job PR Review — Localization & API migration (round 2)
I re-reviewed against the current head ( What changed since round 1Commit Findings (all have inline suggestions)🔶 🔶 Lost 🔹 🔹 Nit — Looks good
Minor (non-blocking, no inline comment)
The two 🔶 items are the only spots where behavior can actually differ from the pre-migration code, so they're worth addressing before merge. |
| MessageEvent.Kind kind = switch (category) { | ||
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | ||
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | ||
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | ||
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | ||
| }; |
There was a problem hiding this comment.
switch over CompilerMessageCategory still has no default. (Round 1 finding, not yet addressed.) A null category throws an NPE, and adding a new enum constant later would throw MatchException. The old convertCategory fell back to INFO. OutputParser.newMessage already keeps a default, so mirror it here:
| MessageEvent.Kind kind = switch (category) { | |
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | |
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | |
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | |
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | |
| }; | |
| MessageEvent.Kind kind = switch (category) { | |
| case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR; | |
| case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING; | |
| case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO; | |
| case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS; | |
| default -> MessageEvent.Kind.INFO; | |
| }; |
| public CompileContext.MessageBuilder url(String url) { | ||
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | ||
| return this; | ||
| } |
There was a problem hiding this comment.
Lost null-guard on the URL (still open). The old message() did url == null ? null : findFileByUrl(url); the new url() calls it unconditionally, so .url(null) would NPE. Note too that the VFS lookup used to run inside the runReadAction that now wraps add(), and findFileByUrl is expected under a read lock. Restoring the guard at minimum:
| public CompileContext.MessageBuilder url(String url) { | |
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } | |
| public CompileContext.MessageBuilder url(String url) { | |
| myFile = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } |
| Application.get().runReadAction(() -> { | ||
| if (myFile != null) { | ||
| FilePosition position = | ||
| new FilePosition(new File(Objects.requireNonNull(myFile.getCanonicalPath())), myRow - 1, myColumn); |
There was a problem hiding this comment.
myRow - 1 now yields -2 when position() isn't called. Commit fa4920f changed the default from 0 to -1. That is correct for OutputParser, which passes myRow straight through (-1 = unknown line). But here FilePosition receives myRow - 1, so the un-positioned case went from -1 (the conventional unknown-line sentinel under the old 0 default) to -2. If a file-bearing message can ever reach add() without position(), guard the conversion:
| new FilePosition(new File(Objects.requireNonNull(myFile.getCanonicalPath())), myRow - 1, myColumn); | |
| new FilePosition(new File(Objects.requireNonNull(myFile.getCanonicalPath())), myRow < 0 ? -1 : myRow - 1, myColumn); |
| public CompileContext.MessageBuilder url(String url) { | ||
| myUrl = url; | ||
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | ||
| return this; | ||
| } |
There was a problem hiding this comment.
Lost null-guard on the URL (still open). Same as the previous round: the old message() guarded with url == null ? null : findFileByUrl(url). The new url() calls findFileByUrl(url) unconditionally, so .url(null) NPEs. Also, this VFS lookup previously ran inside runReadAction (now only add() is wrapped), and findFileByUrl generally wants a read lock. Restore the guard:
| public CompileContext.MessageBuilder url(String url) { | |
| myUrl = url; | |
| myFile = VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } | |
| public CompileContext.MessageBuilder url(String url) { | |
| myUrl = url; | |
| myFile = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url); | |
| return this; | |
| } |
| checkCancelTask.cancel(); | ||
| parser.setStopped(true); | ||
| LocalizeValue title = ApacheAntImplLocalize.antBuildLocalHistoryLabel(buildFile.getName()); | ||
| LocalizeValue buildFileName = LocalizeValue.ofNullable(buildFile.getName()); |
There was a problem hiding this comment.
Nit (still open): buildFile.getName() is effectively non-null, so LocalizeValue.of(...) matches the actual contract more accurately than ofNullable(...).
| LocalizeValue buildFileName = LocalizeValue.ofNullable(buildFile.getName()); | |
| LocalizeValue buildFileName = LocalizeValue.of(buildFile.getName()); |
No description provided.