Repository navigation
Fixing compilation errors after platform localization. Some refactoring - #84
Conversation
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 1m 50s —— View job PR #84 review
What I foundMost of the diff is reformatting to 4-space indents, anonymous classes replaced by lambdas, pattern-matching
The other changes look fine. The lambda rewrites in I didn't run a build; this was a read-only review. I couldn't check the |
| public String getLocationString() { | ||
| PsiDirectory directory = file.getContainingDirectory(); | ||
| return ItemPresentationProvider.getItemPresentation(directory).getPresentableText().get(); | ||
| } |
There was a problem hiding this comment.
Possible NPE. file.getContainingDirectory() returns null for in-memory or light Groovy files (for example console, scratch, or injected fragments), and getItemPresentation(...) can also return null. The new .getPresentableText().get() adds one more dereference to a chain that was already fragile. Consider guarding it:
| public String getLocationString() { | |
| PsiDirectory directory = file.getContainingDirectory(); | |
| return ItemPresentationProvider.getItemPresentation(directory).getPresentableText().get(); | |
| } | |
| public String getLocationString() { | |
| PsiDirectory directory = file.getContainingDirectory(); | |
| if (directory == null) { | |
| return null; | |
| } | |
| ItemPresentation presentation = ItemPresentationProvider.getItemPresentation(directory); | |
| return presentation == null ? null : presentation.getPresentableText().get(); | |
| } |
| @Override | ||
| public LocalizeValue getPresentableText() { | ||
| return LocalizeValue.of(getName()); | ||
| } |
There was a problem hiding this comment.
Inconsistent with GrDynamicImplicitProperty. That class uses LocalizeValue.ofNullable(getName()) and marks the method @RequiredReadAction. This one uses LocalizeValue.of(...) without the annotation. Aligning them makes both safe if getName() ever returns null, and keeps the read-action contract the same:
| @Override | |
| public LocalizeValue getPresentableText() { | |
| return LocalizeValue.of(getName()); | |
| } | |
| @Override | |
| @RequiredReadAction | |
| public LocalizeValue getPresentableText() { | |
| return LocalizeValue.ofNullable(getName()); | |
| } |
| import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; | ||
| import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; | ||
| import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; | ||
| import org.jspecify.annotations.Nullable; |
There was a problem hiding this comment.
Mixed nullability annotations. This file now uses org.jspecify.annotations.Nullable alongside jakarta.annotation.Nonnull (line 38). The sibling GrDynamicImplicitProperty and GroovyScriptClass still use jakarta.annotation.Nullable. Either keep jakarta.annotation.Nullable here for now, or move the whole file to jspecify (@NullMarked plus jspecify @Nullable, dropping @Nonnull). Mixing the two in one class makes the nullness contract harder to read and analyse.
| if (psiClass == null) { | ||
| return null; | ||
| @Override | ||
| public @Nullable PsiClass getContainingClassElement() { |
There was a problem hiding this comment.
Nit: the annotation style here (public @Nullable PsiClass ... as a type-use) differs from the rest of the file and the module (@Nullable on its own line, for example line 139). If the file stays on jakarta annotations (see the comment on line 49), this needs to go back to the declaration-annotation form anyway:
| public @Nullable PsiClass getContainingClassElement() { | |
| @Nullable | |
| public PsiClass getContainingClassElement() { |
| public LocalizeValue getPresentableText() { | ||
| String name = getName(); | ||
| return LocalizeValue.ofNullable(name).orIfEmpty(LocalizeValue.localizeTODO("<unnamed>")); | ||
| } |
There was a problem hiding this comment.
Minor: getName() reads myFile.getName(), and the sibling getIcon() here is annotated @RequiredReadAction. For consistency with the other getPresentableText() overrides in this PR, consider annotating this one too. The ternary also reads a bit more directly than ofNullable(...).orIfEmpty(...):
| public LocalizeValue getPresentableText() { | |
| String name = getName(); | |
| return LocalizeValue.ofNullable(name).orIfEmpty(LocalizeValue.localizeTODO("<unnamed>")); | |
| } | |
| @Override | |
| @RequiredReadAction | |
| public LocalizeValue getPresentableText() { | |
| String name = getName(); | |
| return name != null ? LocalizeValue.of(name) : LocalizeValue.localizeTODO("<unnamed>"); | |
| } |
No description provided.