IDEA-111715: implements for enum constant without class initializer

This commit is contained in:
Anna Kozlova
2013-08-09 12:05:12 +02:00
parent 34d1ba56c6
commit 5ca0622cf4
4 changed files with 50 additions and 1 deletions

View File

@@ -72,7 +72,9 @@ public class ImplementMethodsFix extends LocalQuickFixAndIntentionActionOnPsiEle
if (editor == null || !FileModificationService.getInstance().prepareFileForWrite(myPsiElement.getContainingFile())) return;
if (myPsiElement instanceof PsiEnumConstant) {
final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement, ((PsiEnumConstant)myPsiElement).getContainingClass(), true);
final boolean hasClassInitializer = ((PsiEnumConstant)myPsiElement).getInitializingClass() != null;
final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement,
((PsiEnumConstant)myPsiElement).getContainingClass(), hasClassInitializer);
if (chooser == null) return;
final List<PsiMethodMember> selectedElements = chooser.getSelectedElements();

View File

@@ -0,0 +1,9 @@
// "Implement Methods" "true"
enum E {
A {
public void foo() {
}
};
abstract void foo();
}

View File

@@ -0,0 +1,5 @@
// "Implement Methods" "true"
enum E {
<caret>A;
public abstract void foo();
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* 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.intellij.codeInsight;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixAvailabilityTestCase;
/**
* User: anna
* Date: 10/7/11
*/
public class ImplementMethodsTest extends LightQuickFixAvailabilityTestCase {
public void test() throws Exception {
doAllTests();
}
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods";
}
}