write action (IDEA-84255)

This commit is contained in:
anna
2012-04-09 20:29:45 +02:00
parent 37f41bf73f
commit a7a754eade
4 changed files with 67 additions and 3 deletions
@@ -0,0 +1,24 @@
/*
* Copyright 2000-2012 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.
*/
enum E{
E1 {
@Override
public void foo() {
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
}
};
public abstract void foo();
}
@@ -0,0 +1,19 @@
/*
* Copyright 2000-2012 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.
*/
enum E{
E1;
public abstract void fo<caret>o();
}
@@ -2,6 +2,7 @@ package com.intellij.codeInsight;
import com.intellij.codeInsight.generation.OverrideImplementUtil;
import com.intellij.codeInsight.generation.PsiMethodMember;
import com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -97,6 +98,20 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
assertFalse(strings.toString(), strings.contains("HierarchicalMethodSignatureImpl: A([])"));
}
public void testEnumConstant() throws Exception {
String name = getTestName(false);
configureByFile("/codeInsight/overrideImplement/before" + name + ".java");
int offset = getEditor().getCaretModel().getOffset();
PsiElement context = getFile().findElementAt(offset);
PsiMethod psiMethod = PsiTreeUtil.getParentOfType(context, PsiMethod.class);
assert psiMethod != null;
final PsiClass aClass = psiMethod.getContainingClass();
assert aClass != null && aClass.isEnum();
final PsiField[] fields = aClass.getFields();
new ImplementAbstractMethodHandler(getProject(), getEditor(), psiMethod).implementInClass(fields);
checkResultByFile("/codeInsight/overrideImplement/after" + name + ".java");
}
private void doTest(boolean copyJavadoc) throws Exception {
String name = getTestName(false);
configureByFile("/codeInsight/overrideImplement/before" + name + ".java");