Skip to content

Fixing compilation after platform update. Some refactoring#296

Merged
VISTALL merged 1 commit intoconsulo:masterfrom
unv-unv:compilation-fix
Apr 21, 2026
Merged

Fixing compilation after platform update. Some refactoring#296
VISTALL merged 1 commit intoconsulo:masterfrom
unv-unv:compilation-fix

Conversation

@unv-unv
Copy link
Copy Markdown
Contributor

@unv-unv unv-unv commented Apr 21, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 from String to LocalizeValue across many macros.
  • Add/adjust @RequiredReadAction annotations 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;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
return lookupItems;
return result.isEmpty() ? null : result.toArray(new LookupElement[0]);

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +66
PsiManager instance = PsiManager.getInstance(context.getProject());

String paramResult = params[0].calculateResult(context).toString();
if (paramResult == null) {
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

if (query != null) {
Set<LookupElement> set = new LinkedHashSet<>();
String secondParamValue = params.length > 1 ? params[1].calculateResult(context).toString() : null;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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.

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

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +112
if (findInClass != null && !object.getContainingClass().equals(findInClass)) {
continue;
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

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

Suggested change
if (findInClass != null && !object.getContainingClass().equals(findInClass)) {
continue;
if (findInClass != null) {
PsiClass containingClass = object.getContainingClass();
if (containingClass == null || !containingClass.equals(findInClass)) {
continue;
}

Copilot uses AI. Check for mistakes.
@VISTALL VISTALL merged commit 7fe6ba8 into consulo:master Apr 21, 2026
5 checks passed
@unv-unv unv-unv deleted the compilation-fix branch April 21, 2026 13:56
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.

3 participants