Skip to content

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

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

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

Conversation

@unv-unv

@unv-unv unv-unv commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@unv-unv

unv-unv commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@claude review pr with inline comments

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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


PR review: inline comments posted

  • Read the PR diff and its context
  • Analyze changes
  • Post inline review comments with one-click suggestions (review)

Summary

The PR correctly moves ElementDescriptionProvider and the structure-view presentations from String to LocalizeValue. The InlineRuleDialog change also removes a double wrap. I posted 9 inline comments, all small:

  • BnfDescriptionProvider.java:47-50: two LocalizeValue results are joined with +, which depends on LocalizeValue.toString(). Calling .get() explicitly is safer.
  • BnfDescriptionProvider.java:61: two separate localizeTODO literals instead of one concatenated string, so each can later become its own localize key.
  • BnfStructureViewFactory.java:158 and LivePreviewStructureViewFactory.java:148/151/158: these strings are data or debug output, so LocalizeValue.of fits better than localizeTODO.
  • BnfStructureViewFactory.java:163 and LivePreviewStructureViewFactory.java:161: use String.valueOf(x) instead of "" + x.
  • LivePreviewStructureViewFactory.java:48: this is the first org.jspecify import in the repo. Neither the pom nor module-info declares it, so it only resolves transitively, and the file now mixes jakarta @Nonnull with jspecify @Nullable.

I didn't compile the project because Consulo dependencies aren't available in this runner.

@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.

Reviewed by Claude. The PR correctly follows the ElementDescriptionProvider / PresentableNodeDescriptor move from String to LocalizeValue, and the InlineRuleDialog simplification (no more double wrapping) is a nice touch. All the inline notes are small:

  • Correctness/robustness: BnfDescriptionProvider concatenates two LocalizeValues and relies on their toString(); calling .get() explicitly is safer.
  • Localization semantics: localizeTODO is used on dynamic or debug strings that will never become localize keys; LocalizeValue.of fits better there.
  • Nullability: the jspecify @Nullable in LivePreviewStructureViewFactory is the first jspecify import in the module and only resolves transitively.

I couldn't compile locally because Consulo dependencies aren't available in this runner.

Comment on lines +47 to +50
return LocalizeValue.of(
getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE) + " " +
"'" + getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE) + "'"
);

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.

The recursive getElementDescription(...) calls now return LocalizeValue, so this concatenation goes through LocalizeValue.toString() without saying so. If toString() ever gives something other than the resolved text, the usage-view node text breaks without any error. I'd call .get() explicitly so the intent is clear and the result doesn't depend on toString():

Suggested change
return LocalizeValue.of(
getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE) + " " +
"'" + getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE) + "'"
);
return LocalizeValue.of(
getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE).get() + " " +
"'" + getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE).get() + "'"
);

if (location == UsageViewTypeLocation.INSTANCE) {
BnfRule rule = PsiTreeUtil.getParentOfType(psiElement, BnfRule.class);
return (rule == null ? "Grammar " : "Rule ") + "Attribute";
return LocalizeValue.localizeTODO((rule == null ? "Grammar " : "Rule ") + "Attribute");

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: building the text before passing it to localizeTODO means a later migration to real localize keys has to untangle the concatenation. Two literal strings map 1:1 onto future keys:

Suggested change
return LocalizeValue.localizeTODO((rule == null ? "Grammar " : "Rule ") + "Attribute");
return rule == null ? LocalizeValue.localizeTODO("Grammar Attribute") : LocalizeValue.localizeTODO("Rule Attribute");

}
String suffix = attrList.size() > 1 ? " & " + attrList.size() + " more..." : " ";
return "Attributes { " + getAttrDisplayName(firstAttr) + suffix + "}";
return LocalizeValue.localizeTODO("Attributes { " + getAttrDisplayName(firstAttr) + suffix + "}");

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: most of this string is user data (the attribute name and value), and the rest is formatting. localizeTODO marks text that should eventually become a localize key, but a concatenated string can't be turned into one. Use LocalizeValue.of(...), as you did for the other data-driven presentations in this method, or a parameterized localize template later.

Suggested change
return LocalizeValue.localizeTODO("Attributes { " + getAttrDisplayName(firstAttr) + suffix + "}");
return LocalizeValue.of("Attributes { " + getAttrDisplayName(firstAttr) + suffix + "}");

return LocalizeValue.of(file.getName());
}
return "" + element;
return LocalizeValue.of("" + element);

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: String.valueOf is the idiomatic replacement for "" + x:

Suggested change
return LocalizeValue.of("" + element);
return LocalizeValue.of(String.valueOf(element));


import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
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.

This is the only org.jspecify import in the repo. grammar-kit/pom.xml and module-info.java don't declare it, so it only resolves transitively (presumably through consulo.annotation). If that's intentional, fine. Just be aware that this file now mixes jakarta.annotation.Nonnull with jspecify @Nullable. You could keep jakarta here for consistency with the rest of the module, or migrate the module to @NullMarked in a separate change.

IElementType elementType = node != null ? node.getElementType() : null;
if (element instanceof LeafPsiElement) {
return elementType + ": '" + element.getText() + "'";
return LocalizeValue.localizeTODO(elementType + ": '" + element.getText() + "'");

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.

This is a debug PSI dump (element type plus raw source text), so it will never be translated. localizeTODO is misleading here; LocalizeValue.of fits better. The same applies to lines 151 and 158.

Suggested change
return LocalizeValue.localizeTODO(elementType + ": '" + element.getText() + "'");
return LocalizeValue.of(elementType + ": '" + element.getText() + "'");

}
else if (element instanceof PsiErrorElement errorElem) {
return "PsiErrorElement: '" + errorElem.getErrorDescription() + "'";
return LocalizeValue.localizeTODO("PsiErrorElement: '" + errorElem.getErrorDescription() + "'");

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.

Same as above: this is a debug dump, not translatable UI text.

Suggested change
return LocalizeValue.localizeTODO("PsiErrorElement: '" + errorElem.getErrorDescription() + "'");
return LocalizeValue.of("PsiErrorElement: '" + errorElem.getErrorDescription() + "'");

BnfFile file = (BnfFile)rule.getContainingFile();
String className = getRulePsiClassName(rule, getPsiClassFormat(file));
return className + ": '" + StringUtil.first(element.getText(), 30, true) + "'";
return LocalizeValue.localizeTODO(className + ": '" + StringUtil.first(element.getText(), 30, true) + "'");

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.

Same as above.

Suggested change
return LocalizeValue.localizeTODO(className + ": '" + StringUtil.first(element.getText(), 30, true) + "'");
return LocalizeValue.of(className + ": '" + StringUtil.first(element.getText(), 30, true) + "'");

}
}
return elementType + "";
return LocalizeValue.of(elementType + "");

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:

Suggested change
return LocalizeValue.of(elementType + "");
return LocalizeValue.of(String.valueOf(elementType));

@unv-unv

unv-unv commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@claude review pr with inline comments

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @unv-unv's task in 57s —— View job


PR review (re-run): one new inline comment

  • Read the current PR diff (force-pushed 1f2daf3)
  • Check which earlier inline suggestions were applied
  • Post inline comments on anything new (comment)

Applied since the last review ✅

  • BnfDescriptionProvider: explicit .get() before concatenating, and two separate localizeTODO literals for Grammar/Rule Attribute
  • LivePreviewStructureViewFactory: the debug dumps now use LocalizeValue.of
  • String.valueOf(...) replaces "" + x in both structure-view factories

New

  • BnfDescriptionProvider.java:73: the fallback was return null and is now return LocalizeValue.empty(). This provider is a global extension, so it gets asked about every PSI element, not just BNF ones. Please check that the migrated ElementDescriptionUtil treats empty() as "not handled, ask the next provider". If it still checks != null, non-BNF elements will get blank descriptions. If the new platform contract says to return empty(), this is fine.

Still open (comments from the earlier review, not re-posted)

  • BnfStructureViewFactory.java:158: localizeTODO("Attributes { " + … + "}") wraps dynamic data. LocalizeValue.of fits better here.
  • LivePreviewStructureViewFactory.java:48: org.jspecify is still the only jspecify import in the module and only resolves transitively. The file mixes it with jakarta @Nonnull.

Everything else looks good: the BnfFindUsagesProvider .get() calls, the InlineRuleDialog simplification, the final cleanups and the added @RequiredReadAction annotations.

I didn't compile the project or check the platform source, because neither the Consulo dependencies nor the platform repo were reachable from this runner.

: LocalizeValue.of(psiElement.getClass().getSimpleName());
}
return null;
return LocalizeValue.empty();

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.

This provider is a global @ExtensionImpl, so it gets asked about every PSI element, including Java, XML and the rest, not just BNF. Before this change, null meant "not mine, ask the next provider". Please check that the migrated ElementDescriptionUtil.getElementDescription treats LocalizeValue.empty() the same way, for example with isEmpty() or == LocalizeValue.empty(), and not with a != null check. If it uses != null, this line would cut off the other providers and leave usage-view and find-usages text blank for non-BNF elements. If the new ElementDescriptionProvider contract says to return empty(), this is fine as written. I could not check the platform source from this runner.

@VISTALL
VISTALL merged commit c8f9fef into consulo:master Oct 11, 2026
1 check passed
@unv-unv
unv-unv deleted the compilation-fix branch October 11, 2026 16:26
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