Added bundle for quick fix messages
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package org.jetbrains.jet.plugin;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetBundle {
|
||||
private static Reference<ResourceBundle> ourBundle;
|
||||
|
||||
@NonNls
|
||||
private static final String BUNDLE = "org.jetbrains.jet.plugin.JetBundle";
|
||||
|
||||
private JetBundle() {
|
||||
}
|
||||
|
||||
public static String message(@NonNls @PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private static ResourceBundle getBundle() {
|
||||
ResourceBundle bundle = null;
|
||||
if (ourBundle != null) bundle = ourBundle.get();
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#quick fix messages
|
||||
add.function.body=Add function body
|
||||
add.primary.constructor=Add primary constructor to {0}
|
||||
add.primary.constructor.family=Add primary constructor
|
||||
add.return.type=Add return type declaration
|
||||
change.accessor.type=Change accessor type
|
||||
change.getter.type=Change getter type to {0}
|
||||
change.setter.type=Change setter parameter type to {0}
|
||||
make.variable.immutable=Make variable immutable
|
||||
make.variable.mutable=Make variable mutable
|
||||
change.variable.mutability.family=Change variable mutability
|
||||
remove.function.body=Remove function body
|
||||
make.element.modifier=Make {0} {1}
|
||||
add.modifier=Add ''{0}'' modifier
|
||||
make.element.not.modifier=Make {0} not {1}
|
||||
remove.modifier=Remove ''{0}'' modifier
|
||||
remove.modifier.family=Remove modifier
|
||||
remove.redundant.modifier=Remove redundant ''{0}'' modifier
|
||||
remove.parts.from.property=Remove {0} from property
|
||||
remove.parts.from.property.family=Remove parts from property
|
||||
remove.right.part.of.binary.expression=Remove right part of a binary expression
|
||||
remove.cast=Remove cast
|
||||
remove.elvis.operator=Remove elvis operator
|
||||
replace.operation.in.binary.expression=Replace operation in a binary expression
|
||||
replace.cast.with.static.assert=Replace a cast with a static assert
|
||||
replace.to.dot.call=Replace to dot call
|
||||
@@ -8,6 +8,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -20,13 +21,13 @@ public class AddFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -51,9 +52,9 @@ public class AddModifierFix extends JetIntentionAction<JetModifierListOwner> {
|
||||
@Override
|
||||
public String getText() {
|
||||
if (modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + getElementName(element) + " " + modifier.getValue();
|
||||
return JetBundle.message("make.element.modifier", getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Add '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("add.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -22,13 +23,13 @@ public class AddPrimaryConstructorFix extends JetIntentionAction<JetClass> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add primary constructor to " + element.getName();
|
||||
return JetBundle.message("add.primary.constructor", element.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add primary constructor";
|
||||
return JetBundle.message("add.primary.constructor.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -27,13 +28,13 @@ public class AddReturnTypeFix extends JetIntentionAction<JetNamedDeclaration> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -30,13 +31,13 @@ public class ChangeAccessorTypeFix extends JetIntentionAction<JetPropertyAccesso
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return (element.isGetter() ? "Change getter " : "Change setter parameter ") + "type to " + type;
|
||||
return element.isGetter() ? JetBundle.message("change.getter.type", type) : JetBundle.message("change.setter.type", type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change accessor type";
|
||||
return JetBundle.message("change.accessor.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -23,13 +24,13 @@ public class ChangeVariableMutabilityFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Make variable " + (element.isVar() ? "immutable" : "mutable");
|
||||
return element.isVar() ? JetBundle.message("make.variable.immutable") : JetBundle.message("make.variable.mutable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change variable mutability";
|
||||
return JetBundle.message("change.variable.mutability.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -26,13 +27,13 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -32,16 +33,16 @@ public class RemoveModifierFix {
|
||||
|
||||
private static String makeText(@Nullable JetModifierListOwner element, JetKeywordToken modifier, boolean isRedundant) {
|
||||
if (isRedundant) {
|
||||
return "Remove redundant '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.redundant.modifier", modifier.getValue());
|
||||
}
|
||||
if (element != null && modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + AddModifierFix.getElementName(element) + " not " + modifier.getValue();
|
||||
return JetBundle.message("make.element.not.modifier", AddModifierFix.getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Remove '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
private static String getFamilyName() {
|
||||
return "Remove modifier fix";
|
||||
return JetBundle.message("remove.modifier.family");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -66,13 +67,13 @@ public class RemovePartsFromPropertyFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove " + partsToRemove(removeGetter, removeSetter, removeInitializer) + " from property";
|
||||
return JetBundle.message("remove.parts.from.property", partsToRemove(removeGetter, removeSetter, removeInitializer));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove parts from property to make it abstract";
|
||||
return JetBundle.message("remove.parts.from.property.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -9,6 +9,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -21,7 +22,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove right part of a binary expression";
|
||||
return JetBundle.message("remove.right.part.of.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +46,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove cast";
|
||||
return JetBundle.message("remove.cast");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove elvis operator";
|
||||
return JetBundle.message("remove.elvis.operator");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -24,7 +25,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace operation in a binary expression";
|
||||
return JetBundle.message("replace.operation.in.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +49,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace a cast with a static assert";
|
||||
return JetBundle.message("replace.cast.with.static.assert");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -21,13 +22,13 @@ public class ReplaceSafeCallToDotCall extends JetIntentionAction<JetElement> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace to dot call";
|
||||
return JetBundle.message("replace.to.dot.call");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace safe call to dot call";
|
||||
return JetBundle.message("replace.to.dot.call");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user