create class from usage: enable inside new expr args (IDEA-66193)

This commit is contained in:
anna
2011-03-11 15:32:27 +01:00
parent 066f5d8ce8
commit d1b5fd26f8
3 changed files with 17 additions and 1 deletions
@@ -52,7 +52,8 @@ public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider
registrar.register(new CreateClassFromUsageFix(ref, CreateClassKind.ENUM));
}
PsiElement parent = PsiTreeUtil.getParentOfType(ref, PsiNewExpression.class, PsiMethod.class);
if (parent instanceof PsiNewExpression && !(ref.getParent() instanceof PsiTypeElement)) {
final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(ref, PsiExpressionList.class);
if (parent instanceof PsiNewExpression && !(ref.getParent() instanceof PsiTypeElement) && (expressionList == null || !PsiTreeUtil.isAncestor(parent, expressionList, false))) {
registrar.register(new CreateClassFromNewFix((PsiNewExpression)parent));
registrar.register(new CreateInnerClassFromNewFix((PsiNewExpression)parent));
}
@@ -0,0 +1,9 @@
// "Create Class 'Foo'" "true"
public class Test {
void foo() {
new Test(Foo.FIELD);
}
}
public class Foo {
}
@@ -0,0 +1,6 @@
// "Create Class 'Foo'" "true"
public class Test {
void foo() {
new Test(F<caret>oo.FIELD);
}
}