JavaElementKind methods renamed; more CommonQuickFixBundle and JavaElementKind usages

GitOrigin-RevId: 93f5b6e974986efb0de86566875d77dc821ffea5
This commit is contained in:
Tagir Valeev
2020-01-22 12:38:49 +07:00
committed by intellij-monorepo-bot
parent b927b6490d
commit 6bd95c28cc
40 changed files with 82 additions and 75 deletions

View File

@@ -43,12 +43,12 @@ public enum CreateClassKind implements ClassKind {
@Override
public String getDescription() {
return myKind.nominative();
return myKind.subject();
}
@Override
public String getDescriptionAccusative() {
return myKind.accusative();
return myKind.object();
}
@NotNull

View File

@@ -1104,10 +1104,10 @@ public class TrackingRunner extends DataFlowRunner {
// Do not use inference inside method itself
return null;
}
message = memberKind.nominative() + " '" + name + "' was inferred to be '" + nullability.getPresentationName() + "'";
message = memberKind.subject() + " '" + name + "' was inferred to be '" + nullability.getPresentationName() + "'";
}
else if (info.isExternal()) {
message = memberKind.nominative() + " '" + name + "' is externally annotated as '" + nullability.getPresentationName() + "'";
message = memberKind.subject() + " '" + name + "' is externally annotated as '" + nullability.getPresentationName() + "'";
}
else if (info.isContainer()) {
PsiAnnotationOwner annoOwner = info.getAnnotation().getOwner();
@@ -1129,10 +1129,10 @@ public class TrackingRunner extends DataFlowRunner {
details = " from " + ((PsiNamedElement)annoOwner).getName();
}
message =
memberKind.nominative() + " '" + name + "' inherits " + details + ", thus '" + nullability.getPresentationName() + "'";
memberKind.subject() + " '" + name + "' inherits " + details + ", thus '" + nullability.getPresentationName() + "'";
}
else {
message = memberKind.nominative() + " '" + name + "' is annotated as '" + nullability.getPresentationName() + "'";
message = memberKind.subject() + " '" + name + "' is annotated as '" + nullability.getPresentationName() + "'";
}
if (info.getAnnotation().getContainingFile() == anchor.getContainingFile()) {
anchor = info.getAnnotation();

View File

@@ -7,31 +7,31 @@ import com.intellij.psi.util.JavaElementKind
object CreateMethodActionGroup : JvmActionGroup {
override fun getDisplayText(data: JvmActionGroup.RenderData?): String {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.METHOD.accusative(), data?.entityName!!)
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.METHOD.`object`(), data?.entityName!!)
}
}
object CreateAbstractMethodActionGroup : JvmActionGroup {
override fun getDisplayText(data: JvmActionGroup.RenderData?): String {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ABSTRACT_METHOD.accusative(), data?.entityName!!)
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ABSTRACT_METHOD.`object`(), data?.entityName!!)
}
}
object CreateFieldActionGroup : JvmActionGroup {
override fun getDisplayText(data: JvmActionGroup.RenderData?): String {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.accusative(), data?.entityName!!)
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.`object`(), data?.entityName!!)
}
}
object CreateConstantActionGroup : JvmActionGroup {
override fun getDisplayText(data: JvmActionGroup.RenderData?): String {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.CONSTANT.accusative(), data?.entityName!!)
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.CONSTANT.`object`(), data?.entityName!!)
}
}
object CreateEnumConstantActionGroup : JvmActionGroup {
override fun getDisplayText(data: JvmActionGroup.RenderData?): String {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.accusative(), data?.entityName!!)
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.`object`(), data?.entityName!!)
}
}

View File

@@ -65,8 +65,8 @@ create.class.from.new.family=Create Class from New
create.class.from.usage.family=Create Class from Usage
create.class.from.usage.text=Create {0} ''{1}''
create.inner.class.from.usage.text=Create inner {0} ''{1}''
create.element.in.class=Create {0} ''{1}'' in ''{2}''
create.constant.from.usage.family=Create Constant From Usage
create.constant.from.usage.full.text=Create constant field ''{0}'' in ''{1}''
create.constructor.from.new.family=Create Constructor from New
create.constructor.from.new.text=Create constructor
create.constructor.from.super.call.family=Create Constructor From super() Call
@@ -76,7 +76,6 @@ create.constructor.text=Create constructor in ''{0}''
create.constructor.matching.super=Create constructor matching super
super.class.constructors.chooser.title=Choose Super Class Constructors
create.field.from.usage.family=Create field from Usage
create.field.from.usage.full.text=Create field ''{0}'' in ''{1}''
target.class.chooser.title=Choose Target Class
new.method.body.template.error.text=Please Correct "New Method Body" Template
new.method.body.template.error.title=File Template Error
@@ -94,11 +93,9 @@ create.local.from.instanceof.usage.text=Insert ''({0}){1}'' declaration
create.member.from.usage.family=Create member from usage
create.method.from.usage.family=Create method from usage
create.method.from.usage.text=Create method ''{0}''
create.method.from.usage.full.text=Create method ''{0}'' in ''{1}''
create.type.parameter.from.usage.family=Create type parameter from usage
create.type.parameter.from.usage.text=Create type parameter ''{0}''
create.type.parameter.from.usage.chooser.title=Place to add type parameter
create.abstract.method.from.usage.full.text=Create abstract method ''{0}'' in ''{1}''
create.parameter.from.usage.family=Create parameter from Usage
create.property.from.usage.family=Create property From Usage
create.property.from.usage.text=Create property ''{0}''
@@ -296,7 +293,6 @@ delete.return.fix.family=Delete return
delete.return.fix.text=Delete return {0}
delete.return.fix.side.effects.text=Delete return {0} and extract side effects
delete.element.fix.text=Delete element
delete.reference.fix.text=Delete reference
delete.unreachable.statement.fix.text=Delete unreachable statement

View File

@@ -44,7 +44,7 @@ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix {
@Override
protected String getText(String varName) {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.accusative(), varName);
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.object(), varName);
}
protected boolean createConstantField() {

View File

@@ -57,7 +57,7 @@ public class CreateLocalFromUsageFix extends CreateVarFromUsageFix {
public @NotNull
static String getMessage(String varName) {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.LOCAL_VARIABLE.accusative(), varName);
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.LOCAL_VARIABLE.object(), varName);
}
@Override

View File

@@ -68,7 +68,7 @@ public class CreateParameterFromUsageFix extends CreateVarFromUsageFix {
@Override
public String getText(String varName) {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.PARAMETER.accusative(), varName);
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.PARAMETER.object(), varName);
}
@Nullable

View File

@@ -15,12 +15,13 @@
*/
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.JavaElementKind;
import com.intellij.util.ObjectUtils;
import com.siyeh.ig.psiutils.CommentTracker;
import org.jetbrains.annotations.Nls;
@@ -32,7 +33,7 @@ public class DeleteElementFix extends LocalQuickFixAndIntentionActionOnPsiElemen
public DeleteElementFix(@NotNull PsiElement element) {
super(element);
myText = null;
myText = CommonQuickFixBundle.message("fix.remove.title", JavaElementKind.fromElement(element).object());
}
public DeleteElementFix(@NotNull PsiElement element, @NotNull @Nls String text) {
@@ -51,7 +52,7 @@ public class DeleteElementFix extends LocalQuickFixAndIntentionActionOnPsiElemen
@NotNull
@Override
public String getFamilyName() {
return QuickFixBundle.message("delete.element.fix.text");
return CommonQuickFixBundle.message("fix.remove.title", JavaElementKind.UNKNOWN.object());
}
@Override

View File

@@ -18,10 +18,12 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.BlockUtils;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.intention.LowPriorityAction;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.JavaElementKind;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.ig.psiutils.CommentTracker;
@@ -51,7 +53,8 @@ public class DeleteSideEffectsAwareFix extends LocalQuickFixAndIntentionActionOn
myExpressionPtr = manager.createSmartPsiElementPointer(expression);
List<PsiExpression> sideEffects = SideEffectChecker.extractSideEffectExpressions(expression);
if (sideEffects.isEmpty()) {
myMessage = QuickFixBundle.message("delete.element.fix.text");
JavaElementKind kind = statement instanceof PsiExpressionStatement ? JavaElementKind.EXPRESSION : JavaElementKind.STATEMENT;
myMessage = CommonQuickFixBundle.message("fix.remove.title", kind.object());
}
else {
PsiStatement[] statements = StatementExtractor.generateStatements(sideEffects, expression);

View File

@@ -31,13 +31,13 @@ public class RemoveUnusedParameterFix extends LocalQuickFixAndIntentionActionOnP
@NotNull
@Override
public String getText() {
return CommonQuickFixBundle.message("fix.remove.title.x", JavaElementKind.PARAMETER.accusative(), myName);
return CommonQuickFixBundle.message("fix.remove.title.x", JavaElementKind.PARAMETER.object(), myName);
}
@Override
@NotNull
public String getFamilyName() {
return QuickFixBundle.message("remove.unused.element.family", JavaElementKind.PARAMETER.accusative());
return QuickFixBundle.message("remove.unused.element.family", JavaElementKind.PARAMETER.object());
}
@Override

View File

@@ -51,13 +51,13 @@ public class RemoveUnusedVariableFix implements IntentionAction {
@Override
@NotNull
public String getText() {
return CommonQuickFixBundle.message("fix.remove.title.x", JavaElementKind.fromElement(myVariable).accusative(), myVariable.getName());
return CommonQuickFixBundle.message("fix.remove.title.x", JavaElementKind.fromElement(myVariable).object(), myVariable.getName());
}
@Override
@NotNull
public String getFamilyName() {
return QuickFixBundle.message("remove.unused.element.family", JavaElementKind.VARIABLE.accusative());
return QuickFixBundle.message("remove.unused.element.family", JavaElementKind.VARIABLE.object());
}
@Override

View File

@@ -111,7 +111,7 @@ public class CreateClassOrPackageFix extends LocalQuickFixAndIntentionActionOnPs
@NotNull
public String getText() {
return CommonQuickFixBundle.message("fix.create.title.x",
(myClassKind == null ? JavaElementKind.PACKAGE : myClassKind.getElementKind()).accusative(),
(myClassKind == null ? JavaElementKind.PACKAGE : myClassKind.getElementKind()).object(),
myPresentation);
}

View File

@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.JavaElementKind
/**
* This action renders a static final field.
@@ -22,7 +23,8 @@ internal class CreateConstantAction(
override fun getActionGroup(): JvmActionGroup = CreateConstantActionGroup
override fun getText(): String = message("create.constant.from.usage.full.text", request.fieldName, getNameForClass(target, false))
override fun getText(): String = message("create.element.in.class", JavaElementKind.CONSTANT.`object`(),
request.fieldName, getNameForClass(target, false))
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
JavaFieldRenderer(project, true, target, request).doRender()

View File

@@ -28,7 +28,7 @@ internal class CreateEnumConstantAction(
override fun getActionGroup(): JvmActionGroup = CreateEnumConstantActionGroup
override fun getText(): String = CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.accusative(), request.fieldName)
override fun getText(): String = CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.`object`(), request.fieldName)
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
val name = request.fieldName

View File

@@ -18,6 +18,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.*
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.JavaElementKind
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtil
@@ -25,7 +26,8 @@ internal class CreateFieldAction(target: PsiClass, request: CreateFieldRequest)
override fun getActionGroup(): JvmActionGroup = CreateFieldActionGroup
override fun getText(): String = message("create.field.from.usage.full.text", request.fieldName, getNameForClass(target, false))
override fun getText(): String = message("create.element.in.class", JavaElementKind.FIELD.`object`(),
request.fieldName, getNameForClass(target, false))
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
JavaFieldRenderer(project, false, target, request).doRender()

View File

@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.*
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.JavaElementKind
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtil.setModifierProperty
@@ -45,12 +46,8 @@ internal class CreateMethodAction(
override fun getText(): String {
val what = request.methodName
val where = getNameForClass(target, false)
return if (abstract) {
message("create.abstract.method.from.usage.full.text", what, where)
}
else {
message("create.method.from.usage.full.text", what, where)
}
val kind = if (abstract) JavaElementKind.ABSTRACT_METHOD else JavaElementKind.METHOD
return message("create.element.in.class", kind.`object`(), what, where)
}
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {

View File

@@ -20,6 +20,7 @@ public enum JavaElementKind {
CONSTRUCTOR,
ENUM,
ENUM_CONSTANT,
EXPRESSION,
FIELD,
INITIALIZER,
INTERFACE,
@@ -31,22 +32,23 @@ public enum JavaElementKind {
PATTERN_VARIABLE,
RECORD,
RECORD_COMPONENT,
STATEMENT,
UNKNOWN,
VARIABLE;
/**
* @return human-readable name of the item in nominative case
* @return human-readable name of the item having the subject role in the sentence (nominative case)
*/
@Nls
public @NotNull String nominative() {
public @NotNull String subject() {
return JavaCoreBundle.message("element." + name().toLowerCase(Locale.ROOT), 0);
}
/**
* @return human-readable name of the item in accusative case
* @return human-readable name of the item having the subject role in the sentence (accusative case)
*/
@Nls
public @NotNull String accusative() {
public @NotNull String object() {
return JavaCoreBundle.message("element." + name().toLowerCase(Locale.ROOT), 1);
}
@@ -110,6 +112,12 @@ public enum JavaElementKind {
if (element instanceof PsiClassInitializer) {
return INITIALIZER;
}
if (element instanceof PsiStatement) {
return STATEMENT;
}
if (element instanceof PsiExpression) {
return EXPRESSION;
}
return UNKNOWN;
}
}

View File

@@ -18,6 +18,9 @@ jdk.14.preview.language.level.description=14 (Preview) - Records, patterns, text
jdk.X.language.level.description=X - Experimental features
# These constants are used from JavaElementKind
# When localizing you may use the parameter #0 which signals the desired grammatical case:
# 0 = nominative case (subject)
# 1 = accusative case (object)
element.class=class
element.interface=interface
element.record=record
@@ -37,4 +40,6 @@ element.package=package
element.module=module
element.enum=enum
element.annotation=annotation
element.statement=statement
element.expression=expression
element.unknown=element

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove expression" "true"
class X {
void test() {
for (int i = 0; i < Integer.MAX_VALUE; ) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove expression" "true"
class X {
void test() {
for (int i = 0; i < Integer.MAX_VALUE; i<caret> *= 2) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove expression" "true"
public class Main {
public void test() {
}

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove expression" "true"
public class Main {
public void test() {
2 <caret>+ 2;

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(String[] arr) {
}

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
//comment

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
if(x > -5) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
}

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(String[] arr) {
fo<caret>r (String string : arr) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
i<caret>f(x > 0) //comment

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
if(x > -5) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "false"
// "Remove statement" "false"
class Test {
void test(int x) {
if(x > -5) {

View File

@@ -1,4 +1,4 @@
// "Delete element" "true"
// "Remove statement" "true"
class Test {
void test(int x) {
s<caret>witch(x*2) {}

View File

@@ -19,7 +19,7 @@ class CreateFromUsageOrderTest : LightJavaCodeInsightFixtureTestCase() {
fun `test constant first when uppercase`() {
myFixture.configureByText("_.java", "class A { void usage() { foo(<caret>CCCC); } }")
val action = myFixture.availableIntentions.first()
assertEquals(message("create.constant.from.usage.full.text", "CCCC", "A"), action.text)
assertEquals(message("create.element.in.class", JavaElementKind.CONSTANT.`object`(), "CCCC", "A"), action.text)
}
fun `test local variable first by prefix`() {
@@ -36,7 +36,7 @@ class CreateFromUsageOrderTest : LightJavaCodeInsightFixtureTestCase() {
settings.PARAMETER_NAME_PREFIX = "ppp"
myFixture.configureByText("_.java", "class A { void usage() { foo(<caret>pppbar); } }")
val action = myFixture.availableIntentions.first()
assertEquals(CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.PARAMETER.accusative(), "pppbar"), action.text)
assertEquals(CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.PARAMETER.`object`(), "pppbar"), action.text)
}
}
@@ -45,7 +45,7 @@ class CreateFromUsageOrderTest : LightJavaCodeInsightFixtureTestCase() {
settings.FIELD_NAME_PREFIX = "fff"
myFixture.configureByText("_.java", "class A { void usage() { foo(<caret>fffbar); } }")
val action = myFixture.availableIntentions.first()
assertEquals(message("create.field.from.usage.full.text", "fffbar", "A"), action.text)
assertEquals(message("create.element.in.class", JavaElementKind.FIELD.`object`(), "fffbar", "A"), action.text)
}
}

View File

@@ -8,6 +8,7 @@ fix.unwrap=Unwrap ''{0}''
fix.unwrap.statement=Unwrap ''{0}'' statement
fix.remove=Remove ''{0}''
fix.remove.title=Remove {0}
fix.remove.title.x=Remove {0} ''{1}''
fix.remove.redundant=Remove redundant ''{0}''
fix.remove.statement=Remove ''{0}'' statement

View File

@@ -193,7 +193,6 @@ finalize.declaration.display.name='finalize()' declaration
finalize.declaration.problem.descriptor=<code>#ref()</code> declared #loc
finalize.not.declared.protected.display.name='finalize()' not declared 'protected'
finalize.not.declared.protected.problem.descriptor=<code>#ref()</code> not declared 'protected' #loc
make.protected.quickfix=Make 'protected'
finalize.called.explicitly.display.name='finalize()' called explicitly
finalize.called.explicitly.problem.descriptor=<code>#ref()</code> called explicitly #loc
java.lang.import.display.name='java.lang' import

View File

@@ -49,7 +49,7 @@ public class FinalizeNotProtectedInspection extends BaseInspection {
@Override
@NotNull
public String getFamilyName() {
return InspectionGadgetsBundle.message("make.protected.quickfix");
return InspectionGadgetsBundle.message("change.modifier.quickfix", PsiModifier.PROTECTED);
}
@Override

View File

@@ -1,7 +1,6 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.devkit.codeInsight;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.openapi.project.Project;
@@ -84,7 +83,7 @@ public class CreateClassFixTest extends UsefulTestCase {
EdtTestUtil.runInEdtAndWait(() -> {
IntentionAction resultAction = null;
final String createAction = CommonQuickFixBundle.message(
"fix.create.title.x", (myCreateClass ? JavaElementKind.CLASS : JavaElementKind.INTERFACE).accusative(), myTestName);
"fix.create.title.x", (myCreateClass ? JavaElementKind.CLASS : JavaElementKind.INTERFACE).object(), myTestName);
final List<IntentionAction> actions = myFixture.getAvailableIntentions(getSourceRoot() + "/plugin" + myTestName + ".xml");
for (IntentionAction action : actions) {
if (Comparing.strEqual(action.getText(), createAction)) {

View File

@@ -27,7 +27,7 @@ internal class CreateEnumConstantAction(
override fun getActionGroup(): JvmActionGroup = CreateEnumConstantActionGroup
override fun getText(): String = CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.accusative(), request.fieldName)
override fun getText(): String = CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.ENUM_CONSTANT.`object`(), request.fieldName)
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
val name = request.fieldName

View File

@@ -16,6 +16,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.PsiType
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.JavaElementKind
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtil
import org.jetbrains.plugins.groovy.annotator.intentions.GroovyCreateFieldFromUsageHelper
@@ -36,12 +37,8 @@ internal class CreateFieldAction(
override fun getText(): String {
val what = request.fieldName
val where = getNameForClass(target, false)
return if (constantField) {
message("create.constant.from.usage.full.text", what, where)
}
else {
message("create.field.from.usage.full.text", what, where)
}
val kind = if (constantField) JavaElementKind.CONSTANT else JavaElementKind.FIELD
return message("create.element.in.class", kind.`object`(), what, where)
}
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {

View File

@@ -11,6 +11,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.PsiNameHelper
import com.intellij.psi.PsiType
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.JavaElementKind
import org.jetbrains.plugins.groovy.intentions.base.IntentionUtils.createTemplateForMethod
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier
@@ -39,12 +40,8 @@ internal class CreateMethodAction(
override fun getText(): String {
val what = request.methodName
val where = getNameForClass(target, false)
return if (abstract && !target.isInterface) {
message("create.abstract.method.from.usage.full.text", what, where)
}
else {
message("create.method.from.usage.full.text", what, where)
}
val kind = if (abstract && !target.isInterface) JavaElementKind.ABSTRACT_METHOD else JavaElementKind.METHOD
return message("create.element.in.class", kind.`object`(), what, where)
}
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {

View File

@@ -101,7 +101,7 @@ public class JavaFxUnresolvedFxIdReferenceInspection extends XmlSuppressableInsp
@NotNull
@Override
public String getName() {
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.accusative(), myCanonicalName);
return CommonQuickFixBundle.message("fix.create.title.x", JavaElementKind.FIELD.object(), myCanonicalName);
}
@NotNull