|
15 | 15 | */ |
16 | 16 | package com.jetbrains.python.impl.refactoring.classes.membersManager; |
17 | 17 |
|
18 | | -import java.util.Collection; |
19 | | - |
20 | | -import jakarta.annotation.Nonnull; |
21 | | - |
| 18 | +import com.jetbrains.python.psi.PyClass; |
| 19 | +import consulo.language.editor.refactoring.localize.RefactoringLocalize; |
22 | 20 | import consulo.language.editor.refactoring.ui.ConflictsDialog; |
23 | 21 | import consulo.language.editor.refactoring.ui.RefactoringUIUtil; |
24 | | -import consulo.project.Project; |
25 | 22 | import consulo.language.psi.PsiElement; |
26 | | -import consulo.language.editor.refactoring.RefactoringBundle; |
| 23 | +import consulo.localize.LocalizeValue; |
| 24 | +import consulo.project.Project; |
| 25 | +import consulo.python.impl.localize.PyLocalize; |
27 | 26 | import consulo.util.collection.MultiMap; |
28 | | -import com.jetbrains.python.impl.PyBundle; |
29 | | -import com.jetbrains.python.psi.PyClass; |
| 27 | +import jakarta.annotation.Nonnull; |
| 28 | + |
| 29 | +import java.util.Collection; |
30 | 30 |
|
31 | 31 | /** |
32 | 32 | * Displays error messages about fact that destination class already contains some member infos |
33 | 33 | * or members under refactoring would not be available at the new place. |
34 | 34 | * |
35 | 35 | * @author Ilya.Kazakevich |
36 | 36 | */ |
37 | | -public class MembersConflictDialog extends ConflictsDialog |
38 | | -{ |
39 | | - /** |
40 | | - * @param project project under refactoring |
41 | | - * @param duplicatesConflict duplicates conflicts : that means destination class has the same member. |
42 | | - * If member "foo" already exists in class "bar": pass [bar] -] [foo]. |
43 | | - * @param dependenciesConflicts dependency conflict: list of elements used by member under refactoring and would not be available |
44 | | - * at new destination. If user wants to move method, that uses field "bar" which would not be available at new class, |
45 | | - * pass [bar] field |
46 | | - */ |
47 | | - public MembersConflictDialog(@Nonnull final Project project, @Nonnull final MultiMap<PyClass, PyMemberInfo<?>> duplicatesConflict, @Nonnull final Collection<PyMemberInfo<?>> |
48 | | - dependenciesConflicts) |
49 | | - { |
50 | | - super(project, convertDescription(duplicatesConflict, dependenciesConflicts), null, true, false); |
51 | | - } |
52 | | - |
53 | | - @Nonnull |
54 | | - private static MultiMap<PsiElement, String> convertDescription(@Nonnull final MultiMap<PyClass, PyMemberInfo<?>> duplicateConflictDescriptions, |
55 | | - @Nonnull final Collection<PyMemberInfo<?>> dependenciesConflicts) |
56 | | - { |
57 | | - final MultiMap<PsiElement, String> result = new MultiMap<>(); |
58 | | - for(final PyClass aClass : duplicateConflictDescriptions.keySet()) |
59 | | - { |
60 | | - for(final PyMemberInfo<?> pyMemberInfo : duplicateConflictDescriptions.get(aClass)) |
61 | | - { |
62 | | - final String message = RefactoringBundle.message("0.already.contains.a.1", RefactoringUIUtil.getDescription(aClass, false), RefactoringUIUtil.getDescription(pyMemberInfo.getMember(), |
63 | | - false)); |
64 | | - result.putValue(aClass, message); |
65 | | - } |
66 | | - } |
| 37 | +public class MembersConflictDialog extends ConflictsDialog { |
| 38 | + /** |
| 39 | + * @param project project under refactoring |
| 40 | + * @param duplicatesConflict duplicates conflicts : that means destination class has the same member. |
| 41 | + * If member "foo" already exists in class "bar": pass [bar] -] [foo]. |
| 42 | + * @param dependenciesConflicts dependency conflict: list of elements used by member under refactoring and would not be available |
| 43 | + * at new destination. If user wants to move method, that uses field "bar" which would not be available at new class, |
| 44 | + * pass [bar] field |
| 45 | + */ |
| 46 | + public MembersConflictDialog( |
| 47 | + @Nonnull Project project, |
| 48 | + @Nonnull MultiMap<PyClass, PyMemberInfo<?>> duplicatesConflict, |
| 49 | + @Nonnull Collection<PyMemberInfo<?>> dependenciesConflicts |
| 50 | + ) { |
| 51 | + super(project, convertDescription(duplicatesConflict, dependenciesConflicts), null, true, false); |
| 52 | + } |
67 | 53 |
|
68 | | - for(final PyMemberInfo<?> memberUnderConflict : dependenciesConflicts) |
69 | | - { |
70 | | - result.putValue(memberUnderConflict.getMember(), PyBundle.message("refactoring.will.not.be.accessible", RefactoringUIUtil.getDescription(memberUnderConflict.getMember(), false))); |
71 | | - } |
| 54 | + @Nonnull |
| 55 | + private static MultiMap<PsiElement, LocalizeValue> convertDescription( |
| 56 | + @Nonnull MultiMap<PyClass, PyMemberInfo<?>> duplicateConflictDescriptions, |
| 57 | + @Nonnull Collection<PyMemberInfo<?>> dependenciesConflicts |
| 58 | + ) { |
| 59 | + MultiMap<PsiElement, LocalizeValue> result = new MultiMap<>(); |
| 60 | + for (PyClass aClass : duplicateConflictDescriptions.keySet()) { |
| 61 | + for (PyMemberInfo<?> pyMemberInfo : duplicateConflictDescriptions.get(aClass)) { |
| 62 | + LocalizeValue message = RefactoringLocalize.zeroAlreadyContainsA1( |
| 63 | + RefactoringUIUtil.getDescription(aClass, false), |
| 64 | + RefactoringUIUtil.getDescription( |
| 65 | + pyMemberInfo.getMember(), |
| 66 | + false |
| 67 | + ) |
| 68 | + ); |
| 69 | + result.putValue(aClass, message); |
| 70 | + } |
| 71 | + } |
72 | 72 |
|
| 73 | + for (PyMemberInfo<?> memberUnderConflict : dependenciesConflicts) { |
| 74 | + result.putValue( |
| 75 | + memberUnderConflict.getMember(), |
| 76 | + PyLocalize.refactoringWillNotBeAccessible(RefactoringUIUtil.getDescription(memberUnderConflict.getMember(), false)) |
| 77 | + ); |
| 78 | + } |
73 | 79 |
|
74 | | - return result; |
75 | | - } |
| 80 | + return result; |
| 81 | + } |
76 | 82 | } |
0 commit comments