safe delete of enum constructor parameter (IDEA-22853)

This commit is contained in:
anna
2009-10-20 13:16:17 +04:00
parent 5bb25ccbbc
commit c4406cca52
4 changed files with 37 additions and 2 deletions

View File

@@ -558,8 +558,14 @@ public class JavaSafeDeleteProcessor implements SafeDeleteProcessorDelegate {
ReferencesSearch.search(method).forEach(new Processor<PsiReference>() {
public boolean process(final PsiReference reference) {
final PsiElement element = reference.getElement();
if (element.getParent() instanceof PsiCall) {
final PsiExpressionList argList = ((PsiCall)element.getParent()).getArgumentList();
PsiCall call = null;
if (element instanceof PsiCall) {
call = (PsiCall)element;
} else if (element.getParent() instanceof PsiCall) {
call = (PsiCall)element.getParent();
}
if (call != null) {
final PsiExpressionList argList = call.getArgumentList();
if (argList != null) {
final PsiExpression[] args = argList.getExpressions();
if (index < args.length) {

View File

@@ -0,0 +1,12 @@
public enum UserFlags {
Root("Has super administrative powers" ),
Blacklisted("Probably a spammer" );
public final String description;
public final int mask;
UserFlags(String description) {
this.description = description;
this.mask = 1 << ordinal();
}
}

View File

@@ -0,0 +1,12 @@
public enum UserFlags {
Root("Has super administrative powers", 0),
Blacklisted("Probably a spammer", 1);
public final String description;
public final int mask;
UserFlags(String description, int <caret>position) {
this.description = description;
this.mask = 1 << ordinal();
}
}

View File

@@ -56,6 +56,11 @@ public class SafeDeleteTest extends MultiFileTestCase {
doTest("B");
}
public void testEnumConstructorParameter() throws Exception {
myDoCompare = false;
doTest("UserFlags");
}
private void doTest(@NonNls final String qClassName) throws Exception {
doTest(new PerformAction() {
public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {