invite to type type parameters when completing new Callable

This commit is contained in:
peter
2011-09-16 13:14:21 +02:00
parent ea64e090c3
commit 43eb3e6dc5
5 changed files with 28 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.codeInsight.generation.GenerateMembersUtil;
import com.intellij.codeInsight.generation.OverrideImplementUtil;
import com.intellij.codeInsight.generation.PsiGenerationInfo;
@@ -141,17 +142,9 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
}
}
int identifierEnd = context.getTailOffset();
JavaCompletionUtil.insertParentheses(context, delegate, false, hasParams, forAnonymous);
if (context.getCompletionChar() == '<') {
context.getDocument().insertString(identifierEnd, "<>");
context.setAddCompletionChar(false);
context.getEditor().getCaretModel().moveToOffset(identifierEnd + 1);
}
return hasParams;
return true;
}
private static Runnable generateAnonymousBody(final Editor editor, final PsiFile file) {

View File

@@ -85,11 +85,14 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE
OffsetKey refEnd = context.trackOffset(context.getTailOffset(), false);
boolean fillTypeArgs = false;
boolean fillTypeArgs = context.getCompletionChar() == '<';
if (fillTypeArgs) {
context.setAddCompletionChar(false);
}
if (shouldInsertParentheses(psiClass, position)) {
if (ConstructorInsertHandler.insertParentheses(context, item, psiClass, false)) {
fillTypeArgs = psiClass.hasTypeParameters() && PsiUtil.getLanguageLevel(file).isAtLeast(LanguageLevel.JDK_1_5);
AutoPopupController.getInstance(project).autoPopupParameterInfo(editor, null);
fillTypeArgs |= psiClass.hasTypeParameters() && PsiUtil.getLanguageLevel(file).isAtLeast(LanguageLevel.JDK_1_5);
}
}
else if (insertingAnnotationWithParameters(context, item)) {

View File

@@ -0,0 +1,9 @@
public class Driver {
{
new Fooo<caret>
}
}
interface Foooo<T> {
void bar();
}

View File

@@ -0,0 +1,9 @@
public class Driver {
{
new Foooo<<caret>>()
}
}
interface Foooo<T> {
void bar();
}

View File

@@ -916,6 +916,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
public void testMethodParameterTypeDot() throws Throwable { doAntiTest() }
public void testNewGenericClass() throws Throwable { doTest('\n') }
public void testNewGenericInterface() throws Throwable { doTest() }
//public void testUnfinishedMethodTypeParameter() throws Throwable { doTest() }
public void testSuperProtectedMethod() throws Throwable {
myFixture.addClass """package foo;