mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-53668 - PIEAE: PsiUtilCore.ensureValid
This commit is contained in:
@@ -403,7 +403,11 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
}
|
||||
}
|
||||
for (PsiElement expression : rebindExpressions) {
|
||||
codeStyleManager.shortenClassReferences(expression);
|
||||
//filter out invalid elements which are produced by nested elements:
|
||||
//new expressions/type elements, like: List<List<String>>; new Foo(new Foo()), etc
|
||||
if (expression.isValid()){
|
||||
codeStyleManager.shortenClassReferences(expression);
|
||||
}
|
||||
}
|
||||
new OptimizeImportsProcessor(project, createdFiles.toArray(new PsiFile[createdFiles.size()]), null).run();
|
||||
return createdFiles;
|
||||
@@ -496,20 +500,20 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
|
||||
@Override
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
super.visitNewExpression(expression);
|
||||
final PsiJavaCodeReferenceElement referenceElement = expression.getClassReference();
|
||||
if (referenceElement != null) {
|
||||
decodeRef(referenceElement, oldToNewMap, rebindMap);
|
||||
}
|
||||
super.visitNewExpression(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeElement(PsiTypeElement type) {
|
||||
super.visitTypeElement(type);
|
||||
final PsiJavaCodeReferenceElement referenceElement = type.getInnermostComponentReferenceElement();
|
||||
if (referenceElement != null) {
|
||||
decodeRef(referenceElement, oldToNewMap, rebindMap);
|
||||
}
|
||||
super.visitTypeElement(type);
|
||||
}
|
||||
});
|
||||
for (Map.Entry<PsiJavaCodeReferenceElement, PsiElement> entry : rebindMap.entrySet()) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public class Bar<A> {
|
||||
public Bar(Bar<A> f) {
|
||||
}
|
||||
|
||||
Bar<Bar<A>> foos() {
|
||||
return new Bar<Bar<A>>(new Bar<Bar<A>>(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class Foo<A> {
|
||||
public Foo(Foo<A> f) {
|
||||
}
|
||||
|
||||
Foo<Foo<A>> foos() {
|
||||
return new Foo<Foo<A>>(new Foo<Foo<A>>(null));
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,10 @@ public class CopyClassTest extends CodeInsightTestCase {
|
||||
doTest("Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testRecursiveTypes() throws Exception {
|
||||
doTest("Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testLibraryClass() throws Exception { // IDEADEV-28791
|
||||
JavaCodeStyleSettings javaSettings = getCurrentCodeStyleSettings().getCustomSettings(JavaCodeStyleSettings.class);
|
||||
javaSettings.CLASS_NAMES_IN_JAVADOC = JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_ALWAYS;
|
||||
|
||||
Reference in New Issue
Block a user