Skip to content

Fixing compilation errors after platform localization. Some refactoring - #84

Merged
VISTALL merged 1 commit into
consulo:masterfrom
unv-unv:compilation-fix
Oct 12, 2026
Merged

VISTALL merged 1 commit into
consulo:masterfrom
unv-unv:compilation-fix

Conversation

@unv-unv

@unv-unv unv-unv commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@unv-unv

unv-unv commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@claude review pr with inline comments

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @unv-unv's task in 1m 50s —— View job


PR #84 review

  • Read the diff and repo guidelines
  • Review the 4 changed files
  • Post inline comments with suggestions (review)
  • Summarize

What I found

Most of the diff is reformatting to 4-space indents, anonymous classes replaced by lambdas, pattern-matching instanceof, and new @RequiredReadAction/@RequiredWriteAction annotations. The functional change is moving getPresentableText() from String to LocalizeValue and replacing GroovyBundle with GroovyLocalize. That migration looks correct. I left 5 inline comments; all but the third come as one-click suggestion blocks:

  1. GrFileItemPresentationProvider.java:50-53: possible NPE. getContainingDirectory() can return null for light, in-memory or scratch files, and getItemPresentation(...) can also return null. The new .getPresentableText().get() adds one more unguarded dereference. The suggestion adds null checks.
  2. GrDynamicImplicitMethod.java:270-273: inconsistent with GrDynamicImplicitProperty. This one uses LocalizeValue.of(getName()) with no @RequiredReadAction. The property class uses ofNullable and has the annotation. The suggestion makes them match.
  3. GrDynamicImplicitMethod.java:49: mixed nullability annotations. The file now uses jspecify @Nullable but still uses jakarta @Nonnull, while the sibling classes use jakarta for both. Either keep jakarta in this file, or move the whole file to jspecify (@NullMarked).
  4. GrDynamicImplicitMethod.java:99, nit: the type-use public @Nullable PsiClass placement differs from the rest of the file.
  5. GroovyScriptClass.java:572-575, minor: the suggestion adds @RequiredReadAction to the presentation's getPresentableText() (the getIcon() next to it already has it) and uses a simpler null check instead of ofNullable(...).orIfEmpty(...).

The other changes look fine. The lambda rewrites in GroovyScriptClass (Computable/Condition → lambdas, CachedValueProvider.Result.create) behave the same as before. The @RequiredReadAction on the GroovyScriptClass constructor seems justified, since it calls file.getLanguage().

I didn't run a build; this was a read-only review. I couldn't check the LocalizeValue API signatures because no Consulo artifacts are available locally.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline review from Claude. Overall this is a clean migration of getPresentableText() to LocalizeValue, plus some reformatting. The comments below are mostly small robustness and consistency points.

Comment on lines +50 to +53
public String getLocationString() {
PsiDirectory directory = file.getContainingDirectory();
return ItemPresentationProvider.getItemPresentation(directory).getPresentableText().get();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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();
}

Comment on lines +270 to +273
@Override
public LocalizeValue getPresentableText() {
return LocalizeValue.of(getName());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
@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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
public @Nullable PsiClass getContainingClassElement() {
@Nullable
public PsiClass getContainingClassElement() {

Comment on lines +572 to +575
public LocalizeValue getPresentableText() {
String name = getName();
return LocalizeValue.ofNullable(name).orIfEmpty(LocalizeValue.localizeTODO("<unnamed>"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...):

Suggested change
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>");
}

@VISTALL
VISTALL merged commit 4c48516 into consulo:master Oct 12, 2026
1 check failed
@unv-unv
unv-unv deleted the compilation-fix branch October 12, 2026 16:47
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.

2 participants