mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-65910 - IOE: PsiJavaParserFacadeImpl.createTypeElementFromText
This commit is contained in:
@@ -785,7 +785,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
PsiExpression initializer = myFactory.createExpressionFromText(defaultValue, null);
|
||||
PsiDeclarationStatement declaration =
|
||||
myFactory.createVariableDeclarationStatement(name, callSubstitutor.substitute(paramType), initializer);
|
||||
myFactory.createVariableDeclarationStatement(name, GenericsUtil.getVariableTypeByExpressionType(callSubstitutor.substitute(paramType)), initializer);
|
||||
declaration = (PsiDeclarationStatement)block.addAfter(declaration, null);
|
||||
parmVars[i] = (PsiLocalVariable)declaration.getDeclaredElements()[0];
|
||||
PsiUtil.setModifierProperty(parmVars[i], PsiModifier.FINAL, parm.hasModifierProperty(PsiModifier.FINAL));
|
||||
@@ -794,9 +794,8 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
PsiLocalVariable thisVar = null;
|
||||
PsiClass containingClass = myMethod.getContainingClass();
|
||||
if (!myMethod.hasModifierProperty(PsiModifier.STATIC) && containingClass != null) {
|
||||
PsiType thisType = myFactory.createType(containingClass, callSubstitutor);
|
||||
String[] names = myJavaCodeStyle.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, thisType)
|
||||
.names;
|
||||
PsiType thisType = GenericsUtil.getVariableTypeByExpressionType(myFactory.createType(containingClass, callSubstitutor));
|
||||
String[] names = myJavaCodeStyle.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, thisType).names;
|
||||
String thisVarName = names[0];
|
||||
thisVarName = myJavaCodeStyle.suggestUniqueVariableName(thisVarName, myMethod.getFirstChild(), true);
|
||||
PsiExpression initializer = myFactory.createExpressionFromText("null", null);
|
||||
@@ -1524,18 +1523,4 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
return myReference == null ? Collections.singletonList(myMethod) : Arrays.asList(myReference, myMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
enum E {A, B, C;}
|
||||
class FooBar {
|
||||
public FooBar(E e) {
|
||||
}
|
||||
|
||||
// TODO(jayen): inline (bug in intellij 142.4859.6)
|
||||
public FooBar() {
|
||||
this(E.A);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new FooBar(E.A);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -354,12 +355,12 @@ public class GenericsUtil {
|
||||
return internalCanonicalText != null && internalCanonicalText.equals(type.getCanonicalText());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null")
|
||||
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type) {
|
||||
return getVariableTypeByExpressionType(type, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("null, _ -> null")
|
||||
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) {
|
||||
if (type == null) return null;
|
||||
if (type instanceof PsiCapturedWildcardType) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class B<T> {
|
||||
|
||||
void foo(B<? extends CharSequence> sequences){
|
||||
sequences.bar(t -> t).ba<caret>z();
|
||||
}
|
||||
|
||||
private void baz() {
|
||||
T t = null;
|
||||
}
|
||||
|
||||
<K> B<? super T> bar(Function<? super T, ? super T> f) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class B<T> {
|
||||
|
||||
void foo(B<? extends CharSequence> sequences){
|
||||
Object t1 = null;
|
||||
}
|
||||
|
||||
private void baz() {
|
||||
T t = null;
|
||||
}
|
||||
|
||||
<K> B<? super T> bar(Function<? super T, ? super T> f) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -288,6 +288,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
doTestInlineThisOnly();
|
||||
}
|
||||
|
||||
public void testMakeTypesDenotable() throws Exception {
|
||||
doTestInlineThisOnly();
|
||||
}
|
||||
|
||||
private void doTestInlineThisOnly() {
|
||||
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
|
||||
configureByFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user