Fixing compilation after platform update. Some refactoring#296
Fixing compilation after platform update. Some refactoring#296VISTALL merged 1 commit intoconsulo:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Java plugin’s live-template macros and a few highlighting/analysis handlers to compile against the updated platform APIs (notably localization and read-action annotations), with some mechanical refactoring/formatting.
Changes:
- Migrate
Macro#getPresentableName()implementations fromStringtoLocalizeValueacross many macros. - Add/adjust
@RequiredReadActionannotations on PSI-reading macro/handler methods. - Minor refactors/cleanup in highlighting handlers and analysis action (lambda conversions, formatting, localization plumbing).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/VariableOfTypeMacro.java | Switch presentable name to LocalizeValue, add read-action annotations, small refactor. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/TypeOfVariableMacro.java | Switch presentable name to LocalizeValue, add read-action annotations, pattern matching cleanup. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/SuggestVariableNameMacro.java | Switch presentable name to LocalizeValue, add read-action annotations, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/SuggestIndexNameMacro.java | Switch presentable name to LocalizeValue, small control-flow refactor. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/SuggestFirstVariableNameMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/SubtypesMacro.java | Switch presentable name to LocalizeValue, add read-action for lookup items, lambda conversion. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/RightSideTypeMacro.java | Switch presentable name to LocalizeValue, add read-action annotation, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/QualifiedClassNameMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/MethodReturnTypeMacro.java | Switch presentable name to LocalizeValue, minor refactor. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/MethodParametersMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/MethodNameMacro.java | Switch presentable name to LocalizeValue, adjust initializer naming localization source, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/IterableVariableMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/IterableComponentTypeMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/GuessElementTypeMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/GroovyScriptMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/ExpectedTypeMacro.java | Switch presentable name to LocalizeValue, add read-action annotations, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/DescendantClassesEnumMacro.java | Switch presentable name to LocalizeValue, add read-action annotations, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/CurrentPackageMacro.java | Switch presentable name to LocalizeValue, modernize header comment. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/ComponentTypeOfMacro.java | Switch presentable name to LocalizeValue, formatting (but lookup-items logic needs correction). |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/ClassNameMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/CastToLeftSideTypeMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/ArrayVariableMacro.java | Switch presentable name to LocalizeValue, formatting. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/template/macro/AnnotatedMacro.java | Switch presentable name to LocalizeValue, formatting (but null-safety issues remain). |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/highlighting/HighlightOverridingMethodsHandler.java | Update hint/status text to LocalizeValue usage. |
| plugin/src/main/java/com/intellij/java/impl/codeInsight/highlighting/HighlightExitPointsHandler.java | Add read-action annotations and refactor without behavior change. |
| plugin/src/main/java/com/intellij/java/impl/analysis/BaseClassesAnalysisAction.java | Formatting + notification info adjustment for updated APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Result result = params[0].calculateResult(context); | ||
| if (result == null) { | ||
| return null; | ||
| return lookupItems; |
There was a problem hiding this comment.
In calculateLookupItems(), you build a filtered result list of component-type lookup elements but then return the original lookupItems array. This makes the computation dead and likely returns the wrong suggestions for componentTypeOf(...). Return the computed result array (or null/EMPTY_ARRAY when no component types are found), or remove the unused result construction if the original array is intentionally returned.
| return lookupItems; | |
| return result.isEmpty() ? null : result.toArray(new LookupElement[0]); |
| PsiManager instance = PsiManager.getInstance(context.getProject()); | ||
|
|
||
| String paramResult = params[0].calculateResult(context).toString(); | ||
| if (paramResult == null) { |
There was a problem hiding this comment.
params[0].calculateResult(context) can return null, but the current code immediately calls .toString() on it. This can throw a NullPointerException when the macro is invoked with an invalid/empty parameter; assign the Result to a variable, null-check it, and only then derive the class name string.
|
|
||
| if (query != null) { | ||
| Set<LookupElement> set = new LinkedHashSet<>(); | ||
| String secondParamValue = params.length > 1 ? params[1].calculateResult(context).toString() : null; |
There was a problem hiding this comment.
params[1].calculateResult(context) is used without a null-check (.toString() immediately). If the second parameter is provided but evaluates to null, this will throw; store the Result and handle null (e.g., treat as absent/default) before converting to String/boolean.
| String secondParamValue = params.length > 1 ? params[1].calculateResult(context).toString() : null; | |
| String secondParamValue = null; | |
| if (params.length > 1) { | |
| Result secondParamResult = params[1].calculateResult(context); | |
| if (secondParamResult != null) { | |
| secondParamValue = secondParamResult.toString(); | |
| } | |
| } |
| if (findInClass != null && !object.getContainingClass().equals(findInClass)) { | ||
| continue; |
There was a problem hiding this comment.
object.getContainingClass() can be null (e.g., for top-level classes). The current check !object.getContainingClass().equals(findInClass) can throw a NullPointerException when findInClass is non-null; null-check the containing class before comparing (or skip members with no containing class when filtering is requested).
| if (findInClass != null && !object.getContainingClass().equals(findInClass)) { | |
| continue; | |
| if (findInClass != null) { | |
| PsiClass containingClass = object.getContainingClass(); | |
| if (containingClass == null || !containingClass.equals(findInClass)) { | |
| continue; | |
| } |
No description provided.