mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
change new operator type: anonymous classes processed (IDEA-102236)
This commit is contained in:
+9
-5
@@ -122,10 +122,11 @@ public class ChangeNewOperatorTypeFix implements IntentionAction {
|
||||
}
|
||||
|
||||
if (anonymousClass != null) {
|
||||
final PsiAnonymousClass newAnonymousClass = (PsiAnonymousClass)newExpression.getAnonymousClass().replace(anonymousClass);
|
||||
final PsiClass aClass = PsiUtil.resolveClassInType(toType);
|
||||
assert aClass != null;
|
||||
newAnonymousClass.getBaseClassReference().replace(factory.createClassReferenceElement(aClass));
|
||||
PsiAnonymousClass newAnonymousClass = newExpression.getAnonymousClass();
|
||||
final PsiElement childInside = anonymousClass.getLBrace().getNextSibling();
|
||||
if (childInside != null) {
|
||||
newAnonymousClass.addRange(childInside, anonymousClass.getRBrace().getPrevSibling());
|
||||
}
|
||||
}
|
||||
selection = null;
|
||||
caretOffset = -1;
|
||||
@@ -151,7 +152,10 @@ public class ChangeNewOperatorTypeFix implements IntentionAction {
|
||||
PsiType newType = lType;
|
||||
if (rType instanceof PsiClassType && newType instanceof PsiClassType) {
|
||||
final PsiClassType.ClassResolveResult rResolveResult = ((PsiClassType)rType).resolveGenerics();
|
||||
final PsiClass rClass = rResolveResult.getElement();
|
||||
PsiClass rClass = rResolveResult.getElement();
|
||||
if (rClass instanceof PsiAnonymousClass) {
|
||||
rClass = ((PsiAnonymousClass)rClass).getBaseClassType().resolve();
|
||||
}
|
||||
if (rClass != null) {
|
||||
final PsiClassType.ClassResolveResult lResolveResult = ((PsiClassType)newType).resolveGenerics();
|
||||
final PsiClass lClass = lResolveResult.getElement();
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
// "Change 'new Runnable() {...}' to 'new StringBuffer()'" "true"
|
||||
|
||||
class X {
|
||||
public StringBuffer buf = new StringBuffer(){
|
||||
public void run(){
|
||||
System.out.println("smth");
|
||||
}
|
||||
};
|
||||
public StringBuffer buf = new StringBuffer() {
|
||||
public void run(){
|
||||
System.out.println("smth");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Change 'new Foo<short[]>() {...}' to 'new Boo.Foo<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new Foo<String>() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Change 'new Foo<short[]>() {...}' to 'new Boo.Foo<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new Foo<String>() {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change 'new FooImpl<short[]>() {...}' to 'new Boo.FooImpl<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
abstract class FooImpl<K> extends Foo<K>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new FooImpl<String>() {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Change 'new Foo<short[]>() {...}' to 'new Boo.Foo<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new F<caret>oo<short[]>() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Change 'new Foo<short[]>() {...}' to 'new Boo.Foo<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new F<caret>oo<short[]>() {};
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Change 'new FooImpl<short[]>() {...}' to 'new Boo.FooImpl<String>()'" "true"
|
||||
|
||||
class Boo {
|
||||
abstract class Foo<T>{}
|
||||
abstract class FooImpl<K> extends Foo<K>{}
|
||||
|
||||
private Foo<String> foo()
|
||||
{
|
||||
return new F<caret>ooImpl<short[]>() {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user