Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public void invoke(@Nonnull final Project project, Editor editor, final PsiFile
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiAnonymousClass anonymousClass = findAnonymousClass(file, offset);
if (anonymousClass == null) {
showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionAnonymous().get()));
showErrorMessage(editor, RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionAnonymous()).get());
return;
}
final PsiElement parent = anonymousClass.getParent();
if (parent instanceof PsiEnumConstant) {
showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage("Enum constant can't be converted to inner class"));
showErrorMessage(editor, RefactoringLocalize.cannotPerformRefactoringWithReason(LocalizeValue.localizeTODO("Enum constant can't be converted to inner class")).get());
return;
}
invoke(project, editor, anonymousClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import consulo.codeEditor.Editor;
import consulo.codeEditor.ScrollType;
import consulo.language.editor.refactoring.localize.RefactoringLocalize;
import consulo.localize.LocalizeValue;
import consulo.project.Project;
import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.awt.DialogWrapper;
Expand Down Expand Up @@ -58,8 +59,9 @@ private static void invokeOnElement(Project project, Editor editor, PsiElement e
} else if (element instanceof PsiClass psiClass) {
invoke(psiClass, editor);
} else {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionMethodOrClassName().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME.get(), HelpID.CHANGE_SIGNATURE);
LocalizeValue message =
RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionMethodOrClassName());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME.get(), HelpID.CHANGE_SIGNATURE);
}
}

Expand Down Expand Up @@ -107,8 +109,9 @@ private static void invoke(final PsiClass aClass, Editor editor) {
final PsiTypeParameterList typeParameterList = aClass.getTypeParameterList();
Project project = aClass.getProject();
if (typeParameterList == null) {
final String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.changeclasssignatureNoTypeParameters().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME.get(), HelpID.CHANGE_CLASS_SIGNATURE);
LocalizeValue message =
RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.changeclasssignatureNoTypeParameters());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME.get(), HelpID.CHANGE_CLASS_SIGNATURE);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataCo
if (element instanceof PsiIdentifier) element = element.getParent();

if (!(element instanceof PsiMethod)) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionMethod().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CONVERT_TO_INSTANCE_METHOD);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionMethod());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.CONVERT_TO_INSTANCE_METHOD);
return;
}
if (LOG.isDebugEnabled()) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, Dat
}
}
if (suitableParameters.isEmpty()) {
LocalizeValue message = null;
LocalizeValue message;
if (!classTypesFound) {
message = RefactoringLocalize.converttoinstancemethodNoParametersWithReferenceType();
}
Expand All @@ -105,12 +105,15 @@ else if (!resolvableClassesFound) {
else if (!classesInProjectFound) {
message = RefactoringLocalize.converttoinstancemethodAllReferenceTypeParametersAreNotInProject();
}
LOG.assertTrue(message != null);
else {
LOG.assertTrue(false);
return;
}
Editor editor = dataContext.getData(Editor.KEY);
CommonRefactoringUtil.showErrorHint(
project,
editor,
RefactoringBundle.getCannotRefactorMessage(message.get()),
RefactoringLocalize.cannotPerformRefactoringWithReason(message).get(),
REFACTORING_NAME,
HelpID.CONVERT_TO_INSTANCE_METHOD
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import consulo.annotation.access.RequiredReadAction;
import consulo.language.editor.refactoring.localize.RefactoringLocalize;
import consulo.localize.LocalizeValue;
import jakarta.annotation.Nonnull;

import consulo.dataContext.DataContext;
Expand Down Expand Up @@ -46,14 +47,14 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataCo
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionClass().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionClass());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
return;
}
if (element instanceof PsiField field) {
if (field.getContainingClass() == null) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.theFieldShouldBeDeclaredInAClass().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.theFieldShouldBeDeclaredInAClass());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
return;
}
invoke(project, new PsiElement[]{element}, dataContext);
Expand Down Expand Up @@ -98,10 +99,11 @@ public void invoke(@Nonnull final Project project, @Nonnull final PsiElement[] e
preselectedFields.add(field);
}
else {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.fieldsToBeRefactoredShouldBelongToTheSameClass().get());
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.fieldsToBeRefactoredShouldBelongToTheSameClass()
);
Editor editor = dataContext.getData(Editor.KEY);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
return;
}
}
Expand All @@ -122,10 +124,11 @@ public void invoke(@Nonnull final Project project, @Nonnull final PsiElement[] e
}

if (aClass.isInterface()) {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.encapsulateFieldsRefactoringCannotBeAppliedToInterface().get());
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.encapsulateFieldsRefactoringCannotBeAppliedToInterface()
);
Editor editor = dataContext.getData(Editor.KEY);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import consulo.language.util.IncorrectOperationException;
import consulo.localHistory.LocalHistory;
import consulo.localHistory.LocalHistoryAction;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.project.Project;
import consulo.undoRedo.CommandProcessor;
Expand Down Expand Up @@ -64,8 +65,8 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataCo
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionClass().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_INTERFACE);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionClass());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_INTERFACE);
return;
}
if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import consulo.language.psi.PsiElement;
import consulo.language.psi.PsiFile;
import consulo.language.util.IncorrectOperationException;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.navigation.OpenFileDescriptor;
import consulo.navigation.OpenFileDescriptorFactory;
Expand Down Expand Up @@ -167,21 +168,21 @@ private static ExtractMethodProcessor getProcessor(
) {
if (elements == null || elements.length == 0) {
if (showErrorMessages) {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.selectedBlockShouldRepresentASetOfStatementsOrAnExpression().get()
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.selectedBlockShouldRepresentASetOfStatementsOrAnExpression()
);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_METHOD);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_METHOD);
}
return null;
}

for (PsiElement element : elements) {
if (element instanceof PsiStatement statement && JavaHighlightUtil.isSuperOrThisCall(statement, true, true)) {
if (showErrorMessages) {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.selectedBlockContainsInvocationOfAnotherClassConstructor().get()
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.selectedBlockContainsInvocationOfAnotherClassConstructor()
);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_METHOD);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_METHOD);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import consulo.language.psi.search.ReferencesSearch;
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.project.ProjectPropertiesComponent;
Expand Down Expand Up @@ -1685,10 +1686,10 @@ private void showMultipleExitPointsMessage() {
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null);
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.thereAreMultipleExitPointsInTheSelectedCodeFragment().get()
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.thereAreMultipleExitPointsInTheSelectedCodeFragment()
);
CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId);
CommonRefactoringUtil.showErrorHint(myProject, myEditor, message.get(), myRefactoringName, myHelpId);
WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringLocalize.pressEscapeToRemoveTheHighlighting().get());
}
}
Expand All @@ -1697,9 +1698,9 @@ private void showMultipleExitPointsMessage() {
private void showMultipleOutputMessage(PsiType expressionType) {
if (myShowErrorDialogs) {
StringBuilder buffer = new StringBuilder();
buffer.append(
RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.thereAreMultipleOutputValuesForTheSelectedCodeFragment().get())
);
buffer.append(RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.thereAreMultipleOutputValuesForTheSelectedCodeFragment()
));
buffer.append("\n");
if (myHasExpressionOutput) {
buffer.append(" ").append(RefactoringLocalize.expressionResult()).append(": ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import consulo.language.psi.PsiElement;
import consulo.language.psi.PsiFile;
import consulo.language.util.IncorrectOperationException;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.project.Project;
import consulo.undoRedo.CommandProcessor;
Expand All @@ -59,9 +60,10 @@ public void accept(final PsiElement[] selectedValue) {

private void invokeOnElements(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file, @Nonnull PsiElement[] elements) {
if (elements.length == 0) {
String message = RefactoringBundle
.getCannotRefactorMessage(RefactoringLocalize.selectedBlockShouldRepresentASetOfStatementsOrAnExpression().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.selectedBlockShouldRepresentASetOfStatementsOrAnExpression()
);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import consulo.language.util.IncorrectOperationException;
import consulo.localHistory.LocalHistory;
import consulo.localHistory.LocalHistoryAction;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.project.Project;
import consulo.ui.annotation.RequiredUIAccess;
Expand All @@ -71,8 +72,8 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataCo
PsiElement element = file.findElementAt(offset);
while (true) {
if (element == null || element instanceof PsiFile) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.errorWrongCaretPositionClass().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.errorWrongCaretPositionClass());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
return;
}
if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
Expand All @@ -93,15 +94,16 @@ public void invoke(@Nonnull final Project project, @Nonnull PsiElement[] element

Editor editor = dataContext != null ? dataContext.getData(Editor.KEY) : null;
if (mySubclass.isInterface()) {
String message =
RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.superclassCannotBeExtractedFromAnInterface().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
LocalizeValue message =
RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.superclassCannotBeExtractedFromAnInterface());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
return;
}

if (mySubclass.isEnum()) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.superclassCannotBeExtractedFromAnEnum().get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
LocalizeValue message =
RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.superclassCannotBeExtractedFromAnEnum());
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import consulo.language.editor.refactoring.util.CommonRefactoringUtil;
import consulo.language.psi.PsiElement;
import consulo.language.psi.PsiFile;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.project.Project;
import jakarta.annotation.Nonnull;
Expand Down Expand Up @@ -91,8 +92,9 @@ public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, Dat

Editor editor = dataContext.getData(Editor.KEY);
if (aClass.isInterface()) {
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringLocalize.classIsInterface(aClass.getQualifiedName()).get());
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INHERITANCE_TO_DELEGATION);
LocalizeValue message =
RefactoringLocalize.cannotPerformRefactoringWithReason(RefactoringLocalize.classIsInterface(aClass.getQualifiedName()));
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.INHERITANCE_TO_DELEGATION);
return;
}

Expand All @@ -106,10 +108,10 @@ public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, Dat
final PsiClass[] bases = aClass.getSupers();
@NonNls final String javaLangObject = JavaClassNames.JAVA_LANG_OBJECT;
if (bases.length == 0 || bases.length == 1 && javaLangObject.equals(bases[0].getQualifiedName())) {
String message = RefactoringBundle.getCannotRefactorMessage(
RefactoringLocalize.classDoesNotHaveBaseClassesOrInterfaces(aClass.getQualifiedName()).get()
LocalizeValue message = RefactoringLocalize.cannotPerformRefactoringWithReason(
RefactoringLocalize.classDoesNotHaveBaseClassesOrInterfaces(aClass.getQualifiedName())
);
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INHERITANCE_TO_DELEGATION);
CommonRefactoringUtil.showErrorHint(project, editor, message.get(), REFACTORING_NAME, HelpID.INHERITANCE_TO_DELEGATION);
return;
}

Expand Down
Loading
Loading