bindToClass: avoid creation from text to preserve copyable user data (IDEA-196955)

This commit is contained in:
Anna.Kozlova
2018-08-13 09:53:06 +02:00
parent 1d08367faf
commit 8564699f00
5 changed files with 33 additions and 2 deletions
@@ -648,12 +648,11 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
PsiReferenceParameterList parameterList = getParameterList();
if (parameterList != null) {
PsiElement cur = getReferenceNameElement();
do {
while (cur != parameterList) {
assert cur != null : getText();
cur = cur.getNextSibling();
text.append(cur.getText());
}
while (cur != parameterList);
}
PsiJavaCodeReferenceElement ref;
@@ -664,6 +663,11 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
throw new IncorrectOperationException(e.getMessage() + " [qname=" + qName + " class=" + aClass + ";" + aClass.getClass().getName() + "]");
}
PsiReferenceParameterList refParameterList = ref.getParameterList();
if (parameterList != null && refParameterList != null) {
refParameterList.replace(parameterList);
}
getTreeParent().replaceChildInternal(this, (TreeElement)ref.getNode());
if (!preserveQualification) {
@@ -0,0 +1,12 @@
class Test {
static {
List<MethodCandidate> l = new ArrayList<>();
List<MethodCandidate1> l1 = new ArrayList<>();
}
private static class MethodCandidate {
}
private static class MethodCandidate1 {
}
}
@@ -0,0 +1,12 @@
class Super {
private static class MethodCandidate {
}
static {
List<Super.MethodCandidate> l = new ArrayList<>();
List<Super.MethodCandidate1> l1 = new ArrayList<>();
}
private static class MethodCandidate1 {
}
}
@@ -0,0 +1,2 @@
class Test extends Super{
}
@@ -77,6 +77,7 @@ public class InlineSuperClassTest extends MultiFileTestCase {
public void testTypeParameterBound() { doTest();}
public void testInlineInterfaceDoNotChangeConstructor() { doTest(); }
public void testArrayTypeElements() { doTest(); }
public void testReferencesOnInnerClasses() { doTest(); }
public void testConflictOnMemberNotAccessibleThroughInheritor() { doTest(true, false); }
public void testOneAndKeepReferencesInAnotherInheritor() {
doTest(false, true);