avoid completing new HashSet<String><String>();

This commit is contained in:
peter
2012-05-24 19:29:48 +02:00
parent eea3338114
commit 4f841ee461
4 changed files with 27 additions and 0 deletions
@@ -77,6 +77,19 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
psiClass.getTypeParameters().length > 0 &&
((PsiTypeLookupItem)delegate).calcGenerics(position, context).isEmpty() &&
context.getCompletionChar() != '(';
if (context.getDocument().getTextLength() > context.getTailOffset() &&
context.getDocument().getCharsSequence().charAt(context.getTailOffset()) == '<') {
PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getTailOffset(), PsiJavaCodeReferenceElement.class, false);
if (ref != null) {
PsiReferenceParameterList parameterList = ref.getParameterList();
if (parameterList != null && context.getTailOffset() == parameterList.getTextRange().getStartOffset()) {
context.getDocument().deleteString(parameterList.getTextRange().getStartOffset(), parameterList.getTextRange().getEndOffset());
context.commitDocument();
}
}
}
delegate.handleInsert(context);
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
}
@@ -85,6 +98,7 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
PsiTypeLookupItem.addImportForItem(context, psiClass);
}
insertParentheses(context, delegate, psiClass, !inAnonymous && isAbstract);
if (inAnonymous) {
@@ -0,0 +1,6 @@
class Bar {
{
Koo<String> hs = new Ko<caret><StringX>();
}
}
class Koo<X> {}
@@ -0,0 +1,6 @@
class Bar {
{
Koo<String> hs = new Koo<String>()<caret>;
}
}
class Koo<X> {}
@@ -1339,6 +1339,7 @@ public class ListUtils {
public void testInterfaceImplementationNoCast() { doTest() }
public void testStaticallyImportedMethodsBeforeExpression() { doTest() }
public void testInnerChainedReturnType() { doTest() }
public void testOverwriteGenericsAfterNew() { doTest('\n') }
private CommonCodeStyleSettings getCodeStyleSettings() {
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);