IDEA-105455 (encode type information in type element copy)

This commit is contained in:
Roman Shevchenko
2013-04-17 19:35:42 +02:00
parent dcd8d22ade
commit c362124ffd
2 changed files with 25 additions and 16 deletions
@@ -133,13 +133,11 @@ public class JavaTreeGenerator implements TreeGenerator {
String text = type.getPresentableText();
PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(original.getProject()).getParserFacade();
TreeElement element = (TreeElement)parserFacade.createTypeElementFromText(text, original).getNode();
PsiTypeElement element = parserFacade.createTypeElementFromText(text, original);
PsiTypeElementImpl result = (PsiTypeElementImpl)element.getPsi();
TreeElement result = (TreeElement)element.getNode();
markGeneratedIfNeeded(original, result);
if (type instanceof PsiClassType) {
encodeInfoInTypeElement(result, type);
}
encodeInfoInTypeElement(result, type);
return result;
}
@@ -195,8 +193,7 @@ public class JavaTreeGenerator implements TreeGenerator {
else if (type instanceof PsiIntersectionType) {
encodeInfoInTypeElement(typeElement, ((PsiIntersectionType)type).getRepresentative());
}
else {
LOG.assertTrue(type instanceof PsiClassType);
else if (type instanceof PsiClassType) {
final PsiClassType classType = (PsiClassType)type;
final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
PsiClass referencedClass = resolveResult.getElement();
@@ -1,7 +1,21 @@
/*
* Copyright 2000-2013 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.
*/
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.idea.Bombed;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.CommonClassNames;
@@ -19,7 +33,6 @@ import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
import java.util.Collection;
/**
@@ -210,11 +223,11 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
public void testArrayFromVarargs() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
public void testArrayFromVarargs1() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
public void testEnumArrayFromVarargs() throws Exception {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "E[]"));
}
@@ -261,7 +274,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
public void testAndAndSubexpression() throws Exception {
doTest(new MockIntroduceVariableHandler("ab", true, true, false, "boolean"));
}
public void testSubexpressionWithSpacesInSelection() throws Exception {
doTest(new MockIntroduceVariableHandler("ab", true, true, false, "boolean"));
}
@@ -289,11 +302,11 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
public void testInvalidPostfixExpr() throws Exception {
doTest(new MockIntroduceVariableHandler("a1", true, false, true, "int[]"));
}
public void testPolyadic() throws Exception {
doTest(new MockIntroduceVariableHandler("b1", true, true, true, "boolean"));
}
public void testAssignmentToUnresolvedReference() throws Exception {
doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List<? extends java.util.Collection<?>>"));
}
@@ -358,7 +371,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
fail("Should not be able to perform refactoring");
}
public void testMultiCatchSimple() throws Exception {
doTest(new MockIntroduceVariableHandler("e", true, true, false, "java.lang.Exception", true));
}
@@ -398,7 +411,6 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo.I"));
}
@Bombed(month = Calendar.APRIL, day = 22, user = "Roman")
public void testReturnNonExportedArray() throws Exception {
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {
@Override