Skip to content

Commit 4e6c32e

Browse files
authored
Fixing compilation of RemovingSetupMethodProcessor. Refactoring. (#6)
1 parent 8ae9e2e commit 4e6c32e

2 files changed

Lines changed: 1351 additions & 1602 deletions

File tree

src/main/java/com/intellij/uiDesigner/impl/RemovingSetupMethodProcessor.java

Lines changed: 52 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import com.intellij.java.language.psi.search.PsiShortNamesCache;
66
import com.intellij.uiDesigner.compiler.AsmCodeGenerator;
77
import com.intellij.uiDesigner.impl.make.FormSourceCodeGenerator;
8+
import consulo.annotation.access.RequiredWriteAction;
89
import consulo.language.editor.refactoring.BaseRefactoringProcessor;
910
import consulo.language.editor.refactoring.ui.UsageViewDescriptorAdapter;
1011
import consulo.language.psi.PsiElement;
1112
import consulo.language.psi.PsiFile;
1213
import consulo.language.psi.scope.GlobalSearchScope;
14+
import consulo.localize.LocalizeValue;
1315
import consulo.project.Project;
1416
import consulo.usage.UsageInfo;
1517
import consulo.usage.UsageViewDescriptor;
@@ -22,74 +24,61 @@
2224
* @author VISTALL
2325
* @since 2023-11-14
2426
*/
25-
public class RemovingSetupMethodProcessor extends BaseRefactoringProcessor
26-
{
27-
public RemovingSetupMethodProcessor(@Nonnull Project project)
28-
{
29-
super(project);
30-
}
27+
public class RemovingSetupMethodProcessor extends BaseRefactoringProcessor {
28+
public RemovingSetupMethodProcessor(@Nonnull Project project) {
29+
super(project);
30+
}
3131

32-
@Nonnull
33-
@Override
34-
protected UsageViewDescriptor createUsageViewDescriptor(@Nonnull UsageInfo[] usageInfos)
35-
{
36-
return new UsageViewDescriptorAdapter()
37-
{
38-
@Nonnull
39-
@Override
40-
public PsiElement[] getElements()
41-
{
42-
return new PsiElement[0];
43-
}
32+
@Nonnull
33+
@Override
34+
protected UsageViewDescriptor createUsageViewDescriptor(@Nonnull UsageInfo[] usageInfos) {
35+
return new UsageViewDescriptorAdapter() {
36+
@Nonnull
37+
@Override
38+
public PsiElement[] getElements() {
39+
return new PsiElement[0];
40+
}
4441

45-
@Override
46-
public String getProcessedElementsHeader()
47-
{
48-
return null;
49-
}
50-
};
51-
}
42+
@Override
43+
public String getProcessedElementsHeader() {
44+
return null;
45+
}
46+
};
47+
}
5248

53-
@Nonnull
54-
@Override
55-
protected UsageInfo[] findUsages()
56-
{
57-
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject);
58-
final PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME,
59-
GlobalSearchScope.projectScope(myProject));
49+
@Nonnull
50+
@Override
51+
protected UsageInfo[] findUsages() {
52+
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject);
53+
PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME, GlobalSearchScope.projectScope(myProject));
6054

61-
return Arrays.stream(methods).map(UsageInfo::new).toArray(UsageInfo[]::new);
62-
}
55+
return Arrays.stream(methods).map(UsageInfo::new).toArray(UsageInfo[]::new);
56+
}
6357

64-
@Override
65-
protected boolean isPreviewUsages(@Nonnull UsageInfo[] usages)
66-
{
67-
return false;
68-
}
58+
@Override
59+
protected boolean isPreviewUsages(@Nonnull UsageInfo[] usages) {
60+
return false;
61+
}
6962

70-
@Override
71-
protected void performRefactoring(@Nonnull UsageInfo[] usageInfos)
72-
{
73-
for(UsageInfo usageInfo : usageInfos)
74-
{
75-
final PsiMethod method = (PsiMethod) usageInfo.getElement();
76-
final PsiClass aClass = method.getContainingClass();
77-
if(aClass != null)
78-
{
79-
final PsiFile psiFile = aClass.getContainingFile();
80-
final VirtualFile vFile = psiFile.getVirtualFile();
81-
if(vFile.isWritable())
82-
{
83-
FormSourceCodeGenerator.cleanup(aClass);
84-
}
85-
}
86-
}
87-
}
63+
@Override
64+
@RequiredWriteAction
65+
protected void performRefactoring(@Nonnull UsageInfo[] usageInfos) {
66+
for (UsageInfo usageInfo : usageInfos) {
67+
PsiMethod method = (PsiMethod) usageInfo.getElement();
68+
PsiClass aClass = method.getContainingClass();
69+
if (aClass != null) {
70+
PsiFile psiFile = aClass.getContainingFile();
71+
VirtualFile vFile = psiFile.getVirtualFile();
72+
if (vFile.isWritable()) {
73+
FormSourceCodeGenerator.cleanup(aClass);
74+
}
75+
}
76+
}
77+
}
8878

89-
@Nonnull
90-
@Override
91-
protected String getCommandName()
92-
{
93-
return "Converting Methods";
94-
}
79+
@Nonnull
80+
@Override
81+
protected LocalizeValue getCommandName() {
82+
return LocalizeValue.localizeTODO("Converting Methods");
83+
}
9584
}

0 commit comments

Comments
 (0)