mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
GuessTypeParameters: explicitly set type element to the expected type
This commit is contained in:
@@ -80,6 +80,8 @@ public class GuessTypeParameters {
|
||||
return;
|
||||
}
|
||||
|
||||
typeElement = (PsiTypeElement)typeElement.replace(JavaPsiFacade.getElementFactory(myProject).createTypeElement(info.getType()));
|
||||
|
||||
PsiSubstitutor rawingSubstitutor = getRawingSubstitutor(myProject, context, targetClass);
|
||||
int substitionResult = hasNullSubstitutions(mySubstitutor)
|
||||
? SUBSTITUTED_NONE
|
||||
|
||||
@@ -58,8 +58,10 @@ public class JavaCreateFieldFromUsageHelper extends CreateFieldFromUsageHelper {
|
||||
builder.replaceElement(field.getInitializer(), new EmptyExpression());
|
||||
PsiIdentifier identifier = field.getNameIdentifier();
|
||||
builder.setEndVariableAfter(identifier);
|
||||
field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
|
||||
}
|
||||
|
||||
field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
|
||||
|
||||
editor.getCaretModel().moveToOffset(field.getTextRange().getStartOffset());
|
||||
Template template = builder.buildInlineTemplate();
|
||||
if (ExpectedTypesProvider.processExpectedTypes((ExpectedTypeInfo[])expectedTypes, new PsiTypeVisitor<PsiType>() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create field 'foo'" "true"
|
||||
class Usage {
|
||||
|
||||
void usage(Generic<String> g, List<String> p) {
|
||||
g.foo = p;
|
||||
}
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
|
||||
public List<T> foo;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create field 'foo'" "true"
|
||||
class Usage {
|
||||
|
||||
void usage(Generic<String> g, List<String>[] p) {
|
||||
g.foo = p;
|
||||
}
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
|
||||
public List<T>[] foo;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Create field 'foo'" "true"
|
||||
class Usage {
|
||||
|
||||
void usage(Generic<String> g, List<String> p) {
|
||||
g.f<caret>oo = p;
|
||||
}
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Create field 'foo'" "true"
|
||||
class Usage {
|
||||
|
||||
void usage(Generic<String> g, List<String>[] p) {
|
||||
g.f<caret>oo = p;
|
||||
}
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Create method 'foo'" "true"
|
||||
interface Generic<T> {
|
||||
List<List<T>> foo();
|
||||
}
|
||||
|
||||
class Usage {
|
||||
|
||||
List<List<String>> usage(Generic<String> g) {
|
||||
return g.foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Create method 'foo'" "true"
|
||||
interface Generic<T> {
|
||||
}
|
||||
|
||||
class Usage {
|
||||
|
||||
List<List<String>> usage(Generic<String> g) {
|
||||
return g.fo<caret>o();
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,10 @@ public class CreateFieldFromUsageTest extends LightQuickFixTestCase {
|
||||
doSingleTest();
|
||||
}
|
||||
|
||||
public void testInnerGeneric() { doSingleTest(); }
|
||||
|
||||
public void testInnerGenericArray() { doSingleTest(); }
|
||||
|
||||
protected void doSingleTest() {
|
||||
doSingleTest(getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user