Repository navigation
Fixing compilation errors after platform localization. Some refactoring - #313
Conversation
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 2m 37s —— View job PR review: 11 inline comments posted
Most of the PR is mechanical: Likely bugs
Behavior change to confirm
Localization semantics
Minor
Points to check (no inline comment)
|
| name = LocalizeValue.empty(); | ||
| } | ||
| myHintText = LocalizeValue.localizeTODO( | ||
| CodeInsightBundle.message("no.methods.overriding.0.are.found", classes.size(), name) |
There was a problem hiding this comment.
name is now a LocalizeValue, and it goes into CodeInsightBundle.message(...) (a MessageFormat with an Object... vararg), so the hint text depends on LocalizeValue.toString(). Calling .get() here makes the string explicit:
| CodeInsightBundle.message("no.methods.overriding.0.are.found", classes.size(), name) | |
| CodeInsightBundle.message("no.methods.overriding.0.are.found", classes.size(), name.get()) |
| RefactoringUIUtil.getDescription(fieldInSubClass, true).capitalize().get() + | ||
| " would hide " + RefactoringUIUtil.getDescription(refMember, true) + | ||
| " which is used by moved " + RefactoringUIUtil.getDescription(member, false) |
There was a problem hiding this comment.
getDescription() now returns LocalizeValue, and two of the three calls in this concatenation have no .get(). They rely on LocalizeValue.toString() to produce the text:
| RefactoringUIUtil.getDescription(fieldInSubClass, true).capitalize().get() + | |
| " would hide " + RefactoringUIUtil.getDescription(refMember, true) + | |
| " which is used by moved " + RefactoringUIUtil.getDescription(member, false) | |
| RefactoringUIUtil.getDescription(fieldInSubClass, true).capitalize().get() + | |
| " would hide " + RefactoringUIUtil.getDescription(refMember, true).get() + | |
| " which is used by moved " + RefactoringUIUtil.getDescription(member, false).get() |
| @Override | ||
| @RequiredReadAction | ||
| public LocalizeValue getPresentableText() { | ||
| return LocalizeValue.of(toString()); |
There was a problem hiding this comment.
toString() returns superClass.getName(), which can be null (for example, an anonymous class). The other providers in this PR use ofNullable for PSI names:
| return LocalizeValue.of(toString()); | |
| return LocalizeValue.ofNullable(toString()); |
| public static enum OwnershipType { | ||
| IMPLEMENTS(PlatformIconGroup.gutterImplementingmethod()), | ||
| OVERRIDES(PlatformIconGroup.gutterOverridingmethod()), | ||
| INHERITS(PlatformIconGroup.hierarchySubtypes()); |
There was a problem hiding this comment.
This changes the icon. INHERITS used AllIcons.General.InheritedMethod before and now uses hierarchySubtypes(), which is a different image. IMPLEMENTS and OVERRIDES map 1:1 to the gutter icons. Is the change intended, or does PlatformIconGroup have an inherited-method icon that should be used here?
| return superClass != null ? superClass.getName() : IdeLocalize.nodeStructureviewInvalid().get(); | ||
| } | ||
|
|
||
| @RequiredReadAction |
There was a problem hiding this comment.
hashCode() has @Override but equals() doesn't:
| @RequiredReadAction | |
| @Override | |
| @RequiredReadAction |
| @RequiredReadAction | ||
| public LocalizeValue getPresentableText() { | ||
| if (myName != null) { | ||
| return LocalizeValue.localizeTODO(myName); |
There was a problem hiding this comment.
The VM name (lambda$foo$0) is generated from code and will never be translated, so localizeTODO marks it wrongly. Only the "Lambda" fallback needs localizeTODO. The same applies at line 56.
| return LocalizeValue.localizeTODO(myName); | |
| return LocalizeValue.of(myName); |
| } | ||
| if (element != null) { | ||
| myName = PsiLambdaNameHelper.getVMName(element); | ||
| return LocalizeValue.localizeTODO(myName); |
There was a problem hiding this comment.
Same as line 50: this is a VM name, not UI text.
| return LocalizeValue.localizeTODO(myName); | |
| return LocalizeValue.of(myName); |
| @RequiredReadAction | ||
| public LocalizeValue getPresentableText() { | ||
| if (myName != null) { | ||
| return LocalizeValue.localizeTODO(myName); |
There was a problem hiding this comment.
myName is a generated name like $1, not text to translate. Also, AnonymousClassesSorter parses this value with Integer.parseInt(s.substring(1)), so it must never be localized. Only the "Anonymous" fallback should use localizeTODO. The same applies at line 56.
| return LocalizeValue.localizeTODO(myName); | |
| return LocalizeValue.of(myName); |
| if (element != null) { | ||
| myName = JavaAnonymousClassesHelper.getName((PsiAnonymousClass) element); | ||
| if (myName != null) { | ||
| return LocalizeValue.localizeTODO(myName); |
There was a problem hiding this comment.
Same as line 49.
| return LocalizeValue.localizeTODO(myName); | |
| return LocalizeValue.of(myName); |
| ), ":", ": "); | ||
| } | ||
| boolean dumb = DumbService.isDumb(field.getProject()); | ||
| return LocalizeValue.localizeTODO(StringUtil.replace( |
There was a problem hiding this comment.
This is formatted Java code (name: Type = init), not UI text. PsiMethodTreeElement and PropertyGroup use LocalizeValue.of(...) for the same kind of value:
| return LocalizeValue.localizeTODO(StringUtil.replace( | |
| return LocalizeValue.of(StringUtil.replace( |
| return name != null ? name : JavaBundle.message("dependencies.tree.node.default.package.abbreviation"); | ||
| } else if (object instanceof PsiDirectory && JrtFileSystem.isRoot(((PsiDirectory) object).getVirtualFile())) { | ||
| return JavaBundle.message("jrt.node.short"); | ||
| return ElementDescriptionUtil.getElementDescription(member, UsageViewShortNameLocation.INSTANCE).get(); |
There was a problem hiding this comment.
Small behavior change. Before, a member without a description returned null, which means "not handled" to the nav bar model, so it fell back to the default presentation. Now .get() returns "", which can show an empty nav bar item. To keep the old behavior:
| return ElementDescriptionUtil.getElementDescription(member, UsageViewShortNameLocation.INSTANCE).get(); | |
| LocalizeValue description = ElementDescriptionUtil.getElementDescription(member, UsageViewShortNameLocation.INSTANCE); | |
| return description.isEmpty() ? null : description.get(); |
2c0e1f2 to
e903782
Compare
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 1m 27s —— View job PR review (re-run on
|
| import consulo.localize.LocalizeValue; | ||
| import consulo.project.DumbService; | ||
| import consulo.util.lang.StringUtil; | ||
| import org.jspecify.annotations.Nullable; |
There was a problem hiding this comment.
Now that getPresentableText() returns LocalizeValue instead of @Nullable String, nothing in this file uses @Nullable, so this import is unused:
| import org.jspecify.annotations.Nullable; |
No description provided.