From 9beb436b28b51ec80aa35cf816f89ebab6fd32d8 Mon Sep 17 00:00:00 2001 From: UNV Date: Thu, 10 Sep 2026 03:27:17 +0300 Subject: [PATCH] Sync with JB: option "Shorten FQ names" is always visible. --- .../template/impl/ShortenFQNamesProcessor.java | 11 ++++++----- .../template/impl/ShortenToStaticImportProcessor.java | 9 ++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenFQNamesProcessor.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenFQNamesProcessor.java index fd706dfebd..0aad8c4a1e 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenFQNamesProcessor.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenFQNamesProcessor.java @@ -44,11 +44,7 @@ public KeyWithDefaultValue getKey() { } @Override - public void processText(Project project, - Template template, - Document document, - RangeMarker templateRange, - Editor editor) { + public void processText(Project project, Template template, Document document, RangeMarker templateRange, Editor editor) { try { PsiDocumentManager.getInstance(project).commitDocument(document); JavaCodeStyleManager javaStyle = JavaCodeStyleManager.getInstance(project); @@ -66,4 +62,9 @@ public void processText(Project project, public LocalizeValue getOptionText() { return CodeInsightLocalize.dialogEditTemplateCheckboxShortenFqNames(); } + + @Override + public boolean isVisible(Template template) { + return true; + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenToStaticImportProcessor.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenToStaticImportProcessor.java index e040e460e6..cf9fa88767 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenToStaticImportProcessor.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/template/impl/ShortenToStaticImportProcessor.java @@ -43,7 +43,7 @@ /** * @author Denis Zhdanov - * @since 4/27/11 3:07 PM + * @since 2011-04-27 */ @ExtensionImpl public class ShortenToStaticImportProcessor implements TemplateOptionalProcessor { @@ -57,6 +57,7 @@ public KeyWithDefaultValue getKey() { } @Override + @RequiredReadAction public void processText(Project project, Template template, Document document, RangeMarker templateRange, Editor editor) { PsiDocumentManager.getInstance(project).commitDocument(document); PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); @@ -64,14 +65,14 @@ public void processText(Project project, Template template, Document document, R return; } - List> staticImportTargets = new ArrayList>(); + List> staticImportTargets = new ArrayList<>(); for ( PsiElement element = PsiUtilCore.getElementAtOffset(file, templateRange.getStartOffset()); element != null && element.getTextRange().getStartOffset() < templateRange.getEndOffset(); element = getNext(element)) { for (StaticImporter importer : IMPORTERS) { if (importer.canPerform(element)) { - staticImportTargets.add(new Pair(element, importer)); + staticImportTargets.add(Pair.create(element, importer)); break; } } @@ -85,6 +86,7 @@ public void processText(Project project, Template template, Document document, R } @Nullable + @RequiredReadAction private static PsiElement getNext(PsiElement element) { PsiElement result = element.getNextSibling(); for (PsiElement current = element; current != null && result == null; current = current.getParent()) { @@ -106,6 +108,7 @@ private interface StaticImporter { private static class SingleMemberStaticImporter implements StaticImporter { @Override + @RequiredReadAction public boolean canPerform(PsiElement element) { return AddSingleMemberStaticImportAction.getStaticImportClass(element) != null; }