From 8a70a7e77f1e4357253d699559a2678a972312e9 Mon Sep 17 00:00:00 2001 From: UNV Date: Mon, 20 Oct 2025 22:53:27 +0300 Subject: [PATCH] Adding @ActionImpl annotations to Generate actions. Refactoring and localizing. --- .../actions/BaseGenerateAction.java | 101 ++++--- .../actions/GenerateConstructorAction.java | 24 +- .../actions/GenerateCreateUIAction.java | 63 +++-- .../actions/GenerateEqualsAction.java | 26 +- .../actions/GenerateGetterAction.java | 10 +- .../GenerateGetterAndSetterAction.java | 12 +- .../GenerateGetterSetterBaseAction.java | 11 +- .../actions/GenerateSetterAction.java | 13 +- .../GenerateSuperMethodCallAction.java | 34 ++- .../GenerateSuperMethodCallHandler.java | 107 ++++---- .../actions/JavaGenerateGroup1.java | 59 ++++ .../actions/JavaGenerateGroup2.java | 39 +++ .../impl/generate/GenerateToStringAction.java | 19 +- .../BaseGenerateTestSupportMethodAction.java | 259 +++++++++--------- .../GenerateDataMethodAction.java | 22 +- .../GenerateSetUpMethodAction.java | 17 +- .../GenerateTearDownMethodAction.java | 17 +- .../GenerateTestMethodAction.java | 10 +- .../en_US/consulo.java.JavaLocalize.yaml | 12 + plugin/src/main/resources/META-INF/plugin.xml | 21 -- 20 files changed, 515 insertions(+), 361 deletions(-) create mode 100644 plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup1.java create mode 100644 plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup2.java diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/BaseGenerateAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/BaseGenerateAction.java index 736586280c..d9aa9d0dca 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/BaseGenerateAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/BaseGenerateAction.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.java.impl.codeInsight.generation.actions; +import consulo.annotation.access.RequiredReadAction; import consulo.language.editor.action.CodeInsightActionHandler; import consulo.language.editor.action.CodeInsightAction; import consulo.language.editor.generation.GenerateActionPopupTemplateInjector; import com.intellij.java.language.psi.PsiClass; import com.intellij.java.language.psi.PsiJavaFile; import consulo.language.editor.refactoring.ContextAwareActionHandler; +import consulo.localize.LocalizeValue; import consulo.ui.ex.action.AnAction; import consulo.dataContext.DataContext; import consulo.ui.ex.action.Presentation; @@ -34,59 +35,69 @@ import jakarta.annotation.Nullable; public class BaseGenerateAction extends CodeInsightAction implements GenerateActionPopupTemplateInjector { - private final CodeInsightActionHandler myHandler; - - public BaseGenerateAction(CodeInsightActionHandler handler) { - myHandler = handler; - } + private final CodeInsightActionHandler myHandler; - @Override - protected void update(@Nonnull Presentation presentation, @Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file, @Nonnull DataContext dataContext, @Nullable String actionPlace) { - super.update(presentation, project, editor, file, dataContext, actionPlace); - if (myHandler instanceof ContextAwareActionHandler && presentation.isEnabled()) { - presentation.setEnabled(((ContextAwareActionHandler) myHandler).isAvailableForQuickList(editor, file, dataContext)); + public BaseGenerateAction(CodeInsightActionHandler handler, @Nonnull LocalizeValue text) { + myHandler = handler; + getTemplatePresentation().setTextValue(text); } - } - @Override - @Nullable - public AnAction createEditTemplateAction(DataContext dataContext) { - return null; - } - - @Nonnull - @Override - protected final CodeInsightActionHandler getHandler() { - return myHandler; - } + @Override + protected void update( + @Nonnull Presentation presentation, + @Nonnull Project project, + @Nonnull Editor editor, + @Nonnull PsiFile file, + @Nonnull DataContext dataContext, + @Nullable String actionPlace + ) { + super.update(presentation, project, editor, file, dataContext, actionPlace); + if (myHandler instanceof ContextAwareActionHandler contextAwareHandler && presentation.isEnabled()) { + presentation.setEnabled(contextAwareHandler.isAvailableForQuickList(editor, file, dataContext)); + } + } - @Nullable - protected PsiClass getTargetClass(Editor editor, PsiFile file) { - int offset = editor.getCaretModel().getOffset(); - PsiElement element = file.findElementAt(offset); - if (element == null) { - return null; + @Override + @Nullable + public AnAction createEditTemplateAction(DataContext dataContext) { + return null; } - final PsiClass target = PsiTreeUtil.getParentOfType(element, PsiClass.class); - return target instanceof SyntheticElement ? null : target; - } - @Override - protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { - if (!(file instanceof PsiJavaFile)) { - return false; + @Nonnull + @Override + protected final CodeInsightActionHandler getHandler() { + return myHandler; } - if (file instanceof PsiCompiledElement) { - return false; + + @Nullable + @RequiredReadAction + protected PsiClass getTargetClass(Editor editor, PsiFile file) { + int offset = editor.getCaretModel().getOffset(); + PsiElement element = file.findElementAt(offset); + if (element == null) { + return null; + } + PsiClass target = PsiTreeUtil.getParentOfType(element, PsiClass.class); + return target instanceof SyntheticElement ? null : target; } - PsiDocumentManager.getInstance(project).commitAllDocuments(); + @Override + @RequiredReadAction + protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { + if (!(file instanceof PsiJavaFile)) { + return false; + } + if (file instanceof PsiCompiledElement) { + return false; + } + + PsiDocumentManager.getInstance(project).commitAllDocuments(); - PsiClass targetClass = getTargetClass(editor, file); - return targetClass != null && isValidForClass(targetClass); - } + PsiClass targetClass = getTargetClass(editor, file); + return targetClass != null && isValidForClass(targetClass); + } - protected boolean isValidForClass(final PsiClass targetClass) { - return !targetClass.isInterface(); - } + protected boolean isValidForClass(PsiClass targetClass) { + return !targetClass.isInterface(); + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateConstructorAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateConstructorAction.java index 002e54703f..18700ac9f7 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateConstructorAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateConstructorAction.java @@ -18,19 +18,23 @@ import com.intellij.java.impl.codeInsight.generation.GenerateConstructorHandler; import com.intellij.java.language.psi.PsiAnonymousClass; import com.intellij.java.language.psi.PsiClass; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** - * Action group which contains Generate... actions - * Available in the Java code editor context only + * Action group which contains Generate... actions. + * Available in the Java code editor context only. + * * @author Alexey Kudravtsev - */ + */ +@ActionImpl(id = "GenerateConstructor") public class GenerateConstructorAction extends BaseGenerateAction { - public GenerateConstructorAction() { - super(new GenerateConstructorHandler()); - } + public GenerateConstructorAction() { + super(new GenerateConstructorHandler(), JavaLocalize.actionGenerateconstructorText()); + } - @Override - protected boolean isValidForClass(final PsiClass targetClass) { - return super.isValidForClass(targetClass) && !(targetClass instanceof PsiAnonymousClass); - } + @Override + protected boolean isValidForClass(PsiClass targetClass) { + return super.isValidForClass(targetClass) && !(targetClass instanceof PsiAnonymousClass); + } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateCreateUIAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateCreateUIAction.java index 889f99d786..2ba71f5f1e 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateCreateUIAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateCreateUIAction.java @@ -17,45 +17,48 @@ import com.intellij.java.language.psi.*; import com.intellij.java.language.psi.util.PsiTypesUtil; +import consulo.annotation.access.RequiredReadAction; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** * @author Konstantin Bulenkov */ +@ActionImpl(id = "GenerateCreateUI") public class GenerateCreateUIAction extends BaseGenerateAction { - public GenerateCreateUIAction() { - super(new GenerateCreateUIHandler()); - } + public GenerateCreateUIAction() { + super(new GenerateCreateUIHandler(), JavaLocalize.actionGeneratecreateuiText()); + } - @Override - protected boolean isValidForClass(PsiClass targetClass) { - final PsiModifierList list = targetClass.getModifierList(); - return list != null - && !list.hasModifierProperty(PsiModifier.ABSTRACT) - && !hasCreateUIMethod(targetClass) - && isComponentUI(targetClass); - } + @Override + @RequiredReadAction + protected boolean isValidForClass(PsiClass targetClass) { + return !targetClass.isAbstract() + && !hasCreateUIMethod(targetClass) + && isComponentUI(targetClass); + } - private static boolean hasCreateUIMethod(PsiClass aClass) { - for (PsiMethod method : aClass.findMethodsByName("createUI", false)) { - if (method.hasModifierProperty(PsiModifier.STATIC)) { - final PsiParameter[] parameters = method.getParameterList().getParameters(); - if (parameters.length == 1) { - final PsiType type = parameters[0].getType(); - final PsiClass typeClass = PsiTypesUtil.getPsiClass(type); - return typeClass != null && "javax.swing.JComponent".equals(typeClass.getQualifiedName()); + private static boolean hasCreateUIMethod(PsiClass aClass) { + for (PsiMethod method : aClass.findMethodsByName("createUI", false)) { + if (method.isStatic()) { + PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameters.length == 1) { + PsiType type = parameters[0].getType(); + PsiClass typeClass = PsiTypesUtil.getPsiClass(type); + return typeClass != null && "javax.swing.JComponent".equals(typeClass.getQualifiedName()); + } + } } - } + return false; } - return false; - } - private static boolean isComponentUI(PsiClass aClass) { - while (aClass != null) { - if ("javax.swing.plaf.ComponentUI".equals(aClass.getQualifiedName())) { - return true; - } - aClass = aClass.getSuperClass(); + private static boolean isComponentUI(PsiClass aClass) { + while (aClass != null) { + if ("javax.swing.plaf.ComponentUI".equals(aClass.getQualifiedName())) { + return true; + } + aClass = aClass.getSuperClass(); + } + return false; } - return false; - } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateEqualsAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateEqualsAction.java index 60e0861a54..3823f4b7e5 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateEqualsAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateEqualsAction.java @@ -16,24 +16,30 @@ package com.intellij.java.impl.codeInsight.generation.actions; import com.intellij.java.impl.codeInsight.generation.GenerateEqualsHandler; +import consulo.annotation.access.RequiredReadAction; +import consulo.annotation.component.ActionImpl; import consulo.codeEditor.Editor; import com.intellij.java.language.psi.PsiAnonymousClass; import com.intellij.java.language.psi.PsiClass; +import consulo.java.localize.JavaLocalize; import consulo.language.psi.PsiFile; /** * @author dsl */ +@ActionImpl(id = "GenerateEquals") public class GenerateEqualsAction extends BaseGenerateAction { - public GenerateEqualsAction() { - super(new GenerateEqualsHandler()); - } + public GenerateEqualsAction() { + super(new GenerateEqualsHandler(), JavaLocalize.actionGenerateequalsText()); + } - @Override - protected PsiClass getTargetClass(Editor editor, PsiFile file) { - final PsiClass targetClass = super.getTargetClass(editor, file); - if (targetClass == null || targetClass instanceof PsiAnonymousClass || - targetClass.isEnum()) return null; - return targetClass; - } + @Override + @RequiredReadAction + protected PsiClass getTargetClass(Editor editor, PsiFile file) { + PsiClass targetClass = super.getTargetClass(editor, file); + if (targetClass == null || targetClass instanceof PsiAnonymousClass || targetClass.isEnum()) { + return null; + } + return targetClass; + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAction.java index 7740f9b6ba..66cce7892b 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAction.java @@ -16,14 +16,18 @@ package com.intellij.java.impl.codeInsight.generation.actions; import com.intellij.java.impl.codeInsight.generation.GenerateGetterHandler; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** * Action group which contains Generate... actions * Available in the Java code editor context only + * * @author Alexey Kudravtsev */ +@ActionImpl(id = "GenerateGetter") public class GenerateGetterAction extends GenerateGetterSetterBaseAction { - public GenerateGetterAction() { - super(new GenerateGetterHandler()); - } + public GenerateGetterAction() { + super(new GenerateGetterHandler(), JavaLocalize.actionGenerategetterText()); + } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAndSetterAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAndSetterAction.java index 6f6694aed9..e76c00a933 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAndSetterAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterAndSetterAction.java @@ -16,14 +16,18 @@ package com.intellij.java.impl.codeInsight.generation.actions; import com.intellij.java.impl.codeInsight.generation.GenerateGetterAndSetterHandler; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** * Action group which contains Generate... actions * Available in the Java code editor context only + * * @author Alexey Kudravtsev - */ + */ +@ActionImpl(id = "GenerateGetterAndSetter") public class GenerateGetterAndSetterAction extends GenerateGetterSetterBaseAction { - public GenerateGetterAndSetterAction() { - super(new GenerateGetterAndSetterHandler()); - } + public GenerateGetterAndSetterAction() { + super(new GenerateGetterAndSetterHandler(), JavaLocalize.actionGenerategetterandsetterText()); + } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterSetterBaseAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterSetterBaseAction.java index 9f93496e9f..5799b005ba 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterSetterBaseAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateGetterSetterBaseAction.java @@ -15,15 +15,18 @@ */ package com.intellij.java.impl.codeInsight.generation.actions; -import com.intellij.java.impl.codeInsight.generation.GenerateGetterSetterHandlerBase; +import consulo.language.editor.action.CodeInsightActionHandler; +import consulo.localize.LocalizeValue; +import jakarta.annotation.Nonnull; /** * Action group which contains Generate... actions * Available in the Java code editor context only + * * @author Danila Ponomarenko */ public abstract class GenerateGetterSetterBaseAction extends BaseGenerateAction { - public GenerateGetterSetterBaseAction(GenerateGetterSetterHandlerBase handler) { - super(handler); - } + protected GenerateGetterSetterBaseAction(CodeInsightActionHandler handler, @Nonnull LocalizeValue text) { + super(handler, text); + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSetterAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSetterAction.java index 2cebea5bf1..95cecec432 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSetterAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSetterAction.java @@ -16,15 +16,18 @@ package com.intellij.java.impl.codeInsight.generation.actions; import com.intellij.java.impl.codeInsight.generation.GenerateSetterHandler; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** * Action group which contains Generate... actions * Available in the Java code editor context only + * * @author Alexey Kudravtsev - */ + */ +@ActionImpl(id = "GenerateSetter") public class GenerateSetterAction extends GenerateGetterSetterBaseAction { - public GenerateSetterAction() { - super(new GenerateSetterHandler()); - } - + public GenerateSetterAction() { + super(new GenerateSetterHandler(), JavaLocalize.actionGeneratesetterText()); + } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallAction.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallAction.java index 53a56910ac..adbacad00d 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallAction.java @@ -15,6 +15,9 @@ */ package com.intellij.java.impl.codeInsight.generation.actions; +import consulo.annotation.access.RequiredReadAction; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; import jakarta.annotation.Nonnull; import consulo.language.editor.action.CodeInsightActionHandler; @@ -25,22 +28,25 @@ import com.intellij.java.language.psi.PsiJavaFile; import com.intellij.java.language.psi.PsiMethod; +@ActionImpl(id = "GenerateSuperMethodCall") public class GenerateSuperMethodCallAction extends BaseCodeInsightAction { - @Nonnull - @Override - protected CodeInsightActionHandler getHandler() { - return new GenerateSuperMethodCallHandler(); - } + public GenerateSuperMethodCallAction() { + super(JavaLocalize.actionGenerateSuperMethodCallText(), JavaLocalize.actionGenerateSuperMethodCallDescription()); + } - @Override - protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull final PsiFile file) { - if (!(file instanceof PsiJavaFile)) { - return false; + @Nonnull + @Override + protected CodeInsightActionHandler getHandler() { + return new GenerateSuperMethodCallHandler(); } - PsiMethod method = GenerateSuperMethodCallHandler.canInsertSuper(project, editor, file); - if (method == null) { - return false; + + @Override + @RequiredReadAction + protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { + if (!(file instanceof PsiJavaFile)) { + return false; + } + PsiMethod method = GenerateSuperMethodCallHandler.canInsertSuper(project, editor, file); + return method != null; } - return true; - } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java index 205e422788..31c272696e 100644 --- a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author cdr - */ package com.intellij.java.impl.codeInsight.generation.actions; import com.intellij.java.impl.codeInsight.generation.OverrideImplementUtil; -import com.intellij.java.language.psi.*; +import com.intellij.java.language.psi.HierarchicalMethodSignature; +import com.intellij.java.language.psi.PsiCodeBlock; +import com.intellij.java.language.psi.PsiMethod; +import com.intellij.java.language.psi.PsiStatement; +import consulo.annotation.access.RequiredReadAction; +import consulo.annotation.access.RequiredWriteAction; import consulo.codeEditor.Editor; import consulo.codeEditor.ScrollType; import consulo.language.editor.CodeInsightUtilCore; @@ -35,57 +36,63 @@ import consulo.project.Project; import jakarta.annotation.Nonnull; -import java.util.List; - +/** + * @author cdr + */ public class GenerateSuperMethodCallHandler implements CodeInsightActionHandler { - private static final Logger LOG = Logger.getInstance(GenerateSuperMethodCallHandler.class); + private static final Logger LOG = Logger.getInstance(GenerateSuperMethodCallHandler.class); - @Override - public void invoke(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { - if (!LanguageEditorUtil.checkModificationAllowed(editor)) return; - PsiMethod method = canInsertSuper(project, editor, file); - try { - PsiMethod template = (PsiMethod)method.copy(); + @Override + @RequiredWriteAction + public void invoke(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { + if (!LanguageEditorUtil.checkModificationAllowed(editor)) { + return; + } + PsiMethod method = canInsertSuper(project, editor, file); + try { + PsiMethod template = (PsiMethod) method.copy(); - OverrideImplementUtil.setupMethodBody(template, method, method.getContainingClass()); - PsiStatement superCall = template.getBody().getStatements()[0]; - PsiCodeBlock body = method.getBody(); - PsiElement toGo; - if (body.getLBrace() == null) { - toGo = body.addBefore(superCall, null); - } - else { - toGo = body.addAfter(superCall, body.getLBrace()); - } - toGo = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(toGo); - editor.getCaretModel().moveToOffset(toGo.getTextOffset()); - editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); - } - catch (IncorrectOperationException e) { - LOG.error(e); + OverrideImplementUtil.setupMethodBody(template, method, method.getContainingClass()); + PsiStatement superCall = template.getBody().getStatements()[0]; + PsiCodeBlock body = method.getBody(); + PsiElement toGo; + if (body.getLBrace() == null) { + toGo = body.addBefore(superCall, null); + } + else { + toGo = body.addAfter(superCall, body.getLBrace()); + } + toGo = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(toGo); + editor.getCaretModel().moveToOffset(toGo.getTextOffset()); + editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } } - } - @Override - public boolean startInWriteAction() { - return true; - } + @Override + public boolean startInWriteAction() { + return true; + } - public static PsiMethod canInsertSuper(Project project, Editor editor, PsiFile file) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); + @RequiredReadAction + public static PsiMethod canInsertSuper(Project project, Editor editor, PsiFile file) { + PsiDocumentManager.getInstance(project).commitAllDocuments(); - int offset = editor.getCaretModel().getOffset(); - PsiElement element = file.findElementAt(offset); - if (element == null) return null; - PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(element, PsiCodeBlock.class); - if (codeBlock == null) return null; - if (!(codeBlock.getParent() instanceof PsiMethod)) return null; - PsiMethod method = (PsiMethod)codeBlock.getParent(); - List superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures(); - for (HierarchicalMethodSignature superSignature : superSignatures) { - if (!superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT)) return method; + int offset = editor.getCaretModel().getOffset(); + PsiElement element = file.findElementAt(offset); + if (element == null) { + return null; + } + PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(element, PsiCodeBlock.class); + if (codeBlock != null && codeBlock.getParent() instanceof PsiMethod method) { + for (HierarchicalMethodSignature superSignature : method.getHierarchicalMethodSignature().getSuperSignatures()) { + if (!superSignature.getMethod().isAbstract()) { + return method; + } + } + } + return null; } - - return null; - } } diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup1.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup1.java new file mode 100644 index 0000000000..27093b6d2c --- /dev/null +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup1.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013-2025 consulo.io + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.impl.codeInsight.generation.actions; + +import com.intellij.java.impl.generate.GenerateToStringAction; +import com.intellij.java.impl.testIntegration.GenerateDataMethodAction; +import com.intellij.java.impl.testIntegration.GenerateSetUpMethodAction; +import com.intellij.java.impl.testIntegration.GenerateTearDownMethodAction; +import com.intellij.java.impl.testIntegration.GenerateTestMethodAction; +import consulo.annotation.component.ActionImpl; +import consulo.annotation.component.ActionParentRef; +import consulo.annotation.component.ActionRef; +import consulo.annotation.component.ActionRefAnchor; +import consulo.application.dumb.DumbAware; +import consulo.localize.LocalizeValue; +import consulo.ui.ex.action.AnSeparator; +import consulo.ui.ex.action.DefaultActionGroup; +import consulo.ui.ex.action.IdeActions; + +/** + * @author UNV + * @since 2025-09-23 + */ +@ActionImpl( + id = "JavaGenerateGroup1", + children = { + @ActionRef(type = GenerateTestMethodAction.class), + @ActionRef(type = GenerateSetUpMethodAction.class), + @ActionRef(type = GenerateTearDownMethodAction.class), + @ActionRef(type = GenerateDataMethodAction.class), + @ActionRef(type = AnSeparator.class), + @ActionRef(type = GenerateConstructorAction.class), + @ActionRef(type = GenerateGetterAction.class), + @ActionRef(type = GenerateSetterAction.class), + @ActionRef(type = GenerateGetterAndSetterAction.class), + @ActionRef(type = GenerateEqualsAction.class), + @ActionRef(type = GenerateToStringAction.class), + @ActionRef(type = GenerateCreateUIAction.class) + }, + parents = @ActionParentRef(value = @ActionRef(id = IdeActions.GROUP_GENERATE), anchor = ActionRefAnchor.FIRST) +) +public class JavaGenerateGroup1 extends DefaultActionGroup implements DumbAware { + public JavaGenerateGroup1() { + super(LocalizeValue.empty(), true); + } +} diff --git a/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup2.java b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup2.java new file mode 100644 index 0000000000..adc23a6f97 --- /dev/null +++ b/plugin/src/main/java/com/intellij/java/impl/codeInsight/generation/actions/JavaGenerateGroup2.java @@ -0,0 +1,39 @@ +/* + * Copyright 2013-2025 consulo.io + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.java.impl.codeInsight.generation.actions; + +import consulo.annotation.component.ActionImpl; +import consulo.annotation.component.ActionParentRef; +import consulo.annotation.component.ActionRef; +import consulo.application.dumb.DumbAware; +import consulo.localize.LocalizeValue; +import consulo.ui.ex.action.DefaultActionGroup; +import consulo.ui.ex.action.IdeActions; + +/** + * @author UNV + * @since 2025-09-23 + */ +@ActionImpl( + id = "JavaGenerateGroup2", + children = @ActionRef(type = GenerateSuperMethodCallAction.class), + parents = @ActionParentRef(value = @ActionRef(id = IdeActions.GROUP_GENERATE)) +) +public class JavaGenerateGroup2 extends DefaultActionGroup implements DumbAware { + public JavaGenerateGroup2() { + super(LocalizeValue.empty(), true); + } +} \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/generate/GenerateToStringAction.java b/plugin/src/main/java/com/intellij/java/impl/generate/GenerateToStringAction.java index 139d7125e3..95bcd694f8 100644 --- a/plugin/src/main/java/com/intellij/java/impl/generate/GenerateToStringAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/generate/GenerateToStringAction.java @@ -16,17 +16,16 @@ package com.intellij.java.impl.generate; import com.intellij.java.impl.codeInsight.generation.actions.BaseGenerateAction; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; /** - * This action handles the generation of a toString() method that dumps the fields - * of the class. + * This action handles the generation of a toString() method that dumps the fields of the class. */ -public class GenerateToStringAction extends BaseGenerateAction -{ - - public GenerateToStringAction() - { - super(new GenerateToStringActionHandlerImpl()); - } - +@ActionImpl(id = "Actions.ActionsPlugin.GenerateToString") +public class GenerateToStringAction extends BaseGenerateAction { + public GenerateToStringAction() { + super(new GenerateToStringActionHandlerImpl(), JavaLocalize.actionGenerateToStringText()); + getTemplatePresentation().setDescriptionValue(JavaLocalize.actionGenerateToStringDescription()); + } } \ No newline at end of file diff --git a/plugin/src/main/java/com/intellij/java/impl/testIntegration/BaseGenerateTestSupportMethodAction.java b/plugin/src/main/java/com/intellij/java/impl/testIntegration/BaseGenerateTestSupportMethodAction.java index 4b25ba307c..60dc73dc60 100644 --- a/plugin/src/main/java/com/intellij/java/impl/testIntegration/BaseGenerateTestSupportMethodAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/testIntegration/BaseGenerateTestSupportMethodAction.java @@ -22,7 +22,8 @@ import com.intellij.java.language.psi.PsiClass; import com.intellij.java.language.psi.PsiMethod; import com.intellij.java.language.testIntegration.TestFramework; -import consulo.application.ApplicationManager; +import consulo.annotation.access.RequiredReadAction; +import consulo.annotation.access.RequiredWriteAction; import consulo.codeEditor.Editor; import consulo.codeEditor.EditorPopupHelper; import consulo.ide.impl.ui.impl.PopupChooserBuilder; @@ -36,8 +37,10 @@ import consulo.language.psi.PsiFile; import consulo.language.psi.util.PsiTreeUtil; import consulo.language.util.IncorrectOperationException; +import consulo.localize.LocalizeValue; import consulo.logging.Logger; import consulo.project.Project; +import consulo.ui.annotation.RequiredUIAccess; import consulo.ui.ex.awt.ColoredListCellRenderer; import consulo.ui.ex.awt.JBList; import consulo.ui.ex.popup.JBPopup; @@ -47,165 +50,165 @@ import javax.swing.*; import java.util.Collections; import java.util.List; -import java.util.function.Function; public class BaseGenerateTestSupportMethodAction extends BaseGenerateAction { - protected static final Logger LOG = Logger.getInstance(BaseGenerateTestSupportMethodAction.class); - - public BaseGenerateTestSupportMethodAction(TestIntegrationUtils.MethodKind methodKind) { - super(new MyHandler(methodKind)); - } - - @Override - protected PsiClass getTargetClass(Editor editor, PsiFile file) { - return findTargetClass(editor, file); - } - - @Nullable - private static PsiClass findTargetClass(Editor editor, PsiFile file) { - int offset = editor.getCaretModel().getOffset(); - PsiElement element = file.findElementAt(offset); - return element == null ? null : TestIntegrationUtils.findOuterClass(element); - } - - @Override - protected boolean isValidForClass(PsiClass targetClass) { - List frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass); - if (frameworks.isEmpty()) { - return false; - } + protected static final Logger LOG = Logger.getInstance(BaseGenerateTestSupportMethodAction.class); - for (TestFramework each : frameworks) { - if (isValidFor(targetClass, each)) { - return true; - } + public BaseGenerateTestSupportMethodAction(TestIntegrationUtils.MethodKind methodKind, @Nonnull LocalizeValue text) { + super(new MyHandler(methodKind), text); } - return false; - } - @Override - protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { - if (file instanceof PsiCompiledElement) { - return false; + @Override + @RequiredReadAction + protected PsiClass getTargetClass(Editor editor, PsiFile file) { + return findTargetClass(editor, file); } - PsiDocumentManager.getInstance(project).commitAllDocuments(); + @Nullable + @RequiredReadAction + private static PsiClass findTargetClass(Editor editor, PsiFile file) { + int offset = editor.getCaretModel().getOffset(); + PsiElement element = file.findElementAt(offset); + return element == null ? null : TestIntegrationUtils.findOuterClass(element); + } - PsiClass targetClass = getTargetClass(editor, file); - return targetClass != null && isValidForClass(targetClass); - } + @Override + protected boolean isValidForClass(PsiClass targetClass) { + List frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass); + if (frameworks.isEmpty()) { + return false; + } + for (TestFramework each : frameworks) { + if (isValidFor(targetClass, each)) { + return true; + } + } + return false; + } - protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { - return true; - } + @Override + @RequiredReadAction + protected boolean isValidForFile(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { + if (file instanceof PsiCompiledElement) { + return false; + } - private static class MyHandler implements CodeInsightActionHandler { - private TestIntegrationUtils.MethodKind myMethodKind; + PsiDocumentManager.getInstance(project).commitAllDocuments(); - private MyHandler(TestIntegrationUtils.MethodKind methodKind) { - myMethodKind = methodKind; + PsiClass targetClass = getTargetClass(editor, file); + return targetClass != null && isValidForClass(targetClass); } - public void invoke(@Nonnull Project project, @Nonnull final Editor editor, @Nonnull final PsiFile file) { - final PsiClass targetClass = findTargetClass(editor, file); - final List frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass); - if (frameworks.isEmpty()) { - return; - } + protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { + return true; + } - if (frameworks.size() == 1) { - doGenerate(editor, file, targetClass, frameworks.get(0)); - return; - } + private static class MyHandler implements CodeInsightActionHandler { + private TestIntegrationUtils.MethodKind myMethodKind; - final JList list = new JBList(frameworks.toArray(new TestFramework[frameworks.size()])); - list.setCellRenderer(new ColoredListCellRenderer() { - @Override - protected void customizeCellRenderer(@Nonnull JList jList, TestFramework framework, int i, boolean b, boolean b1) { - setIcon(framework.getIcon()); - append(framework.getName()); + private MyHandler(TestIntegrationUtils.MethodKind methodKind) { + myMethodKind = methodKind; } - }); - - final Runnable runnable = new Runnable() { - public void run() { - TestFramework selected = (TestFramework) list.getSelectedValue(); - if (selected == null) { - return; - } - doGenerate(editor, file, targetClass, selected); - } - }; - PopupChooserBuilder builder = new PopupChooserBuilder(list); - builder.setFilteringEnabled(new Function() { @Override - public String apply(Object o) { - return ((TestFramework) o).getName(); - } - }); - - JBPopup popup = builder - .setTitle("Choose Framework") - .setItemChoosenCallback(runnable) - .setMovable(true) - .createPopup(); + @RequiredUIAccess + public void invoke(@Nonnull Project project, @Nonnull Editor editor, @Nonnull PsiFile file) { + PsiClass targetClass = findTargetClass(editor, file); + List frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass); + if (frameworks.isEmpty()) { + return; + } - EditorPopupHelper.getInstance().showPopupInBestPositionFor(editor, popup); - } + if (frameworks.size() == 1) { + doGenerate(editor, file, targetClass, frameworks.get(0)); + return; + } - private void doGenerate(final Editor editor, final PsiFile file, final PsiClass targetClass, final TestFramework framework) { - if (!CommonRefactoringUtil.checkReadOnlyStatus(file)) { - return; - } + JList list = new JBList<>(frameworks.toArray(new TestFramework[frameworks.size()])); + list.setCellRenderer(new ColoredListCellRenderer<>() { + @Override + protected void customizeCellRenderer(@Nonnull JList jList, TestFramework framework, int i, boolean b, boolean b1) { + setIcon(framework.getIcon()); + append(framework.getName()); + } + }); + + @RequiredUIAccess + Runnable runnable = () -> { + TestFramework selected = list.getSelectedValue(); + if (selected == null) { + return; + } + doGenerate(editor, file, targetClass, selected); + }; + + PopupChooserBuilder builder = new PopupChooserBuilder(list); + builder.setFilteringEnabled(o -> ((TestFramework) o).getName()); + + JBPopup popup = builder + .setTitle("Choose Framework") + .setItemChoosenCallback(runnable) + .setMovable(true) + .createPopup(); + + EditorPopupHelper.getInstance().showPopupInBestPositionFor(editor, popup); + } - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - try { - PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments(); - PsiMethod method = generateDummyMethod(editor, file); - if (method == null) { - return; + @RequiredUIAccess + private void doGenerate(Editor editor, PsiFile file, PsiClass targetClass, TestFramework framework) { + if (!CommonRefactoringUtil.checkReadOnlyStatus(file)) { + return; } - TestIntegrationUtils.runTestMethodTemplate(myMethodKind, framework, editor, targetClass, method, "name", false); - } catch (IncorrectOperationException e) { - HintManager.getInstance().showErrorHint(editor, "Cannot generate method: " + e.getMessage()); - LOG.warn(e); - } + Project project = file.getProject(); + project.getApplication().runWriteAction(() -> { + try { + PsiDocumentManager.getInstance(project).commitAllDocuments(); + PsiMethod method = generateDummyMethod(editor, file); + if (method == null) { + return; + } + + TestIntegrationUtils.runTestMethodTemplate(myMethodKind, framework, editor, targetClass, method, "name", false); + } + catch (IncorrectOperationException e) { + HintManager.getInstance().showErrorHint(editor, "Cannot generate method: " + e.getMessage()); + LOG.warn(e); + } + }); } - }); - } - @Nullable - private static PsiMethod generateDummyMethod(Editor editor, PsiFile file) throws IncorrectOperationException { - final PsiMethod method = TestIntegrationUtils.createDummyMethod(file); - final PsiGenerationInfo info = OverrideImplementUtil.createGenerationInfo(method); + @Nullable + @RequiredWriteAction + private static PsiMethod generateDummyMethod(Editor editor, PsiFile file) throws IncorrectOperationException { + PsiMethod method = TestIntegrationUtils.createDummyMethod(file); + PsiGenerationInfo info = OverrideImplementUtil.createGenerationInfo(method); - int offset = findOffsetToInsertMethodTo(editor, file); - GenerateMembersUtil.insertMembersAtOffset(file, offset, Collections.singletonList(info)); + int offset = findOffsetToInsertMethodTo(editor, file); + GenerateMembersUtil.insertMembersAtOffset(file, offset, Collections.singletonList(info)); - final PsiMethod member = info.getPsiMember(); - return member != null ? CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(member) : null; - } + PsiMethod member = info.getPsiMember(); + return member != null ? CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(member) : null; + } - private static int findOffsetToInsertMethodTo(Editor editor, PsiFile file) { - int result = editor.getCaretModel().getOffset(); + @RequiredReadAction + private static int findOffsetToInsertMethodTo(Editor editor, PsiFile file) { + int result = editor.getCaretModel().getOffset(); - PsiClass classAtCursor = PsiTreeUtil.getParentOfType(file.findElementAt(result), PsiClass.class, false); + PsiClass classAtCursor = PsiTreeUtil.getParentOfType(file.findElementAt(result), PsiClass.class, false); - while (classAtCursor != null && !(classAtCursor.getParent() instanceof PsiFile)) { - result = classAtCursor.getTextRange().getEndOffset(); - classAtCursor = PsiTreeUtil.getParentOfType(classAtCursor, PsiClass.class); - } + while (classAtCursor != null && !(classAtCursor.getParent() instanceof PsiFile)) { + result = classAtCursor.getTextRange().getEndOffset(); + classAtCursor = PsiTreeUtil.getParentOfType(classAtCursor, PsiClass.class); + } - return result; - } + return result; + } - public boolean startInWriteAction() { - return false; + @Override + public boolean startInWriteAction() { + return false; + } } - } } diff --git a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateDataMethodAction.java b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateDataMethodAction.java index 019e979ed1..1db7529933 100644 --- a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateDataMethodAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateDataMethodAction.java @@ -18,18 +18,20 @@ import com.intellij.java.language.testIntegration.JavaTestFramework; import com.intellij.java.language.testIntegration.TestFramework; import com.intellij.java.language.psi.PsiClass; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; +@ActionImpl(id = "GenerateDataMethod") public class GenerateDataMethodAction extends BaseGenerateTestSupportMethodAction { - public GenerateDataMethodAction() { - super(TestIntegrationUtils.MethodKind.DATA); - } + public GenerateDataMethodAction() { + super(TestIntegrationUtils.MethodKind.DATA, JavaLocalize.actionGeneratedatamethodText()); + } - @Override - protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { - if (framework instanceof JavaTestFramework && super.isValidFor(targetClass, framework)) { - return ((JavaTestFramework)framework).isParameterized(targetClass) && ((JavaTestFramework)framework).findParametersMethod( - targetClass) == null; + @Override + protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { + if (framework instanceof JavaTestFramework javaTestFramework && super.isValidFor(targetClass, framework)) { + return javaTestFramework.isParameterized(targetClass) && javaTestFramework.findParametersMethod(targetClass) == null; + } + return false; } - return false; - } } diff --git a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateSetUpMethodAction.java b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateSetUpMethodAction.java index addb5425b9..63942cc8f3 100644 --- a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateSetUpMethodAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateSetUpMethodAction.java @@ -17,14 +17,17 @@ import com.intellij.java.language.testIntegration.TestFramework; import com.intellij.java.language.psi.PsiClass; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; +@ActionImpl(id = "GenerateSetUpMethod") public class GenerateSetUpMethodAction extends BaseGenerateTestSupportMethodAction { - public GenerateSetUpMethodAction() { - super(TestIntegrationUtils.MethodKind.SET_UP); - } + public GenerateSetUpMethodAction() { + super(TestIntegrationUtils.MethodKind.SET_UP, JavaLocalize.actionGeneratesetupmethodText()); + } - @Override - protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { - return super.isValidFor(targetClass, framework) && framework.findSetUpMethod(targetClass) == null; - } + @Override + protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { + return super.isValidFor(targetClass, framework) && framework.findSetUpMethod(targetClass) == null; + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTearDownMethodAction.java b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTearDownMethodAction.java index e51cdcd68a..c626ec0033 100644 --- a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTearDownMethodAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTearDownMethodAction.java @@ -17,14 +17,17 @@ import com.intellij.java.language.testIntegration.TestFramework; import com.intellij.java.language.psi.PsiClass; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; +@ActionImpl(id = "GenerateTearDownMethod") public class GenerateTearDownMethodAction extends BaseGenerateTestSupportMethodAction { - public GenerateTearDownMethodAction() { - super(TestIntegrationUtils.MethodKind.TEAR_DOWN); - } + public GenerateTearDownMethodAction() { + super(TestIntegrationUtils.MethodKind.TEAR_DOWN, JavaLocalize.actionGenerateteardownmethodText()); + } - @Override - protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { - return super.isValidFor(targetClass, framework) && framework.findTearDownMethod(targetClass) == null; - } + @Override + protected boolean isValidFor(PsiClass targetClass, TestFramework framework) { + return super.isValidFor(targetClass, framework) && framework.findTearDownMethod(targetClass) == null; + } } diff --git a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTestMethodAction.java b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTestMethodAction.java index 404fbe6320..aadc42cf54 100644 --- a/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTestMethodAction.java +++ b/plugin/src/main/java/com/intellij/java/impl/testIntegration/GenerateTestMethodAction.java @@ -15,8 +15,12 @@ */ package com.intellij.java.impl.testIntegration; +import consulo.annotation.component.ActionImpl; +import consulo.java.localize.JavaLocalize; + +@ActionImpl(id = "GenerateTestMethod") public class GenerateTestMethodAction extends BaseGenerateTestSupportMethodAction { - public GenerateTestMethodAction() { - super(TestIntegrationUtils.MethodKind.TEST); - } + public GenerateTestMethodAction() { + super(TestIntegrationUtils.MethodKind.TEST, JavaLocalize.actionGeneratetestmethodText()); + } } diff --git a/plugin/src/main/resources/LOCALIZE-LIB/en_US/consulo.java.JavaLocalize.yaml b/plugin/src/main/resources/LOCALIZE-LIB/en_US/consulo.java.JavaLocalize.yaml index 6297061079..4197f57dc7 100644 --- a/plugin/src/main/resources/LOCALIZE-LIB/en_US/consulo.java.JavaLocalize.yaml +++ b/plugin/src/main/resources/LOCALIZE-LIB/en_US/consulo.java.JavaLocalize.yaml @@ -136,6 +136,10 @@ action.WrapReturnValue.description: text: Wrap return value of the specified method with object action.WrapReturnValue.text: text: Wrap Method Re_turn Value... +action.change.type.signature.description: + text: Change type of the return type of the method, field, parameter, variable or class type arguments and correct all references +action.change.type.signature.text: + text: T_ype Migration... action.create.new.module.info.description: text: Create new module-info.java action.create.new.module.info.title: @@ -144,6 +148,14 @@ action.create.new.package.info.description: text: Create new package-info.java action.create.new.package.info.title: text: package-info.java +action.generate.super.method.call.description: + text: Generate super method call +action.generate.super.method.call.text: + text: Super Method Call +action.generate.to.string.description: + text: Generate toString() method +action.generate.to.string.text: + text: to_String() action.go.to.implementation.text: text: Go to implementation(s) action.go.to.overriding.methods.text: diff --git a/plugin/src/main/resources/META-INF/plugin.xml b/plugin/src/main/resources/META-INF/plugin.xml index 98eeba4fd4..9cce1909e7 100644 --- a/plugin/src/main/resources/META-INF/plugin.xml +++ b/plugin/src/main/resources/META-INF/plugin.xml @@ -39,27 +39,6 @@ - - - - - - - - - - - - - - - - - - - - -