normalize declaration fix: enable for fields (IDEA-84563)

This commit is contained in:
anna
2012-04-14 14:22:45 +02:00
parent 06a398831d
commit b0f77cfdb5
6 changed files with 65 additions and 0 deletions

View File

@@ -39,6 +39,10 @@ public class NormalizeDeclarationFix extends InspectionGadgetsFix {
if (parent == null) {
return;
}
if (parent instanceof PsiField) {
parent.normalizeDeclaration();
return;
}
final PsiElement grandParent = parent.getParent();
if (!(grandParent instanceof PsiDeclarationStatement)) {
return;

View File

@@ -0,0 +1,6 @@
package com.siyeh.igfixes.style.multiple_declaration;
public class SimpleStringBuffer {
int i = 0;
int j = 0;
}

View File

@@ -0,0 +1,5 @@
package com.siyeh.igfixes.style.multiple_declaration;
public class SimpleStringBuffer {
int i = 0, j<caret> = 0;
}

View File

@@ -0,0 +1,8 @@
package com.siyeh.igfixes.style.multiple_declaration;
public class SimpleStringBuffer {
String foo() {
int i = 0;
int j = 0;
}
}

View File

@@ -0,0 +1,7 @@
package com.siyeh.igfixes.style.multiple_declaration;
public class SimpleStringBuffer {
String foo() {
int i = 0, j<caret> = 0;
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2012 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.ig.fixes.style;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.IGQuickFixesTestCase;
import com.siyeh.ig.style.MultipleDeclarationInspection;
public class MultipleDeclarationFixTest extends IGQuickFixesTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new MultipleDeclarationInspection());
myRelativePath = "style/multiple_declaration";
myDefaultHint = InspectionGadgetsBundle.message("normalize.declaration.quickfix");
}
public void testLocalVariable() { doTest(); }
public void testField() { doTest(); }
}