mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less hacks in DefaultInsertHandler/overwriting argument list stuff
This commit is contained in:
+2
-3
@@ -36,10 +36,11 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
|
||||
|
||||
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupItem> item) {
|
||||
@SuppressWarnings({"unchecked"}) final LookupItem<PsiClass> delegate = item.getDelegate();
|
||||
delegate.handleInsert(context);
|
||||
|
||||
insertParentheses(context, delegate, delegate.getObject());
|
||||
|
||||
DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), delegate);
|
||||
|
||||
final PsiElement position = SmartCompletionDecorator.getPosition(context, delegate);
|
||||
|
||||
final PsiExpression enclosing = PsiTreeUtil.getContextOfType(position, PsiExpression.class, true);
|
||||
@@ -66,8 +67,6 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
|
||||
}
|
||||
|
||||
public static void insertParentheses(InsertionContext context, LookupItem delegate, final PsiClass psiClass) {
|
||||
PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(context.getEditor().getDocument());
|
||||
|
||||
final PsiElement place = context.getFile().findElementAt(context.getStartOffset());
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper();
|
||||
assert place != null;
|
||||
|
||||
@@ -55,16 +55,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
return TailType.NONE;
|
||||
}
|
||||
};
|
||||
public static final DefaultInsertHandler NO_TAIL_PARENS_HANDLER = new DefaultInsertHandler(){
|
||||
@Override
|
||||
protected TailType getTailType(char completionChar) {
|
||||
return TailType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeEndOfIdentifier(boolean needParenth) {
|
||||
}
|
||||
};
|
||||
|
||||
public void handleInsert(final InsertionContext context, LookupElement item) {
|
||||
super.handleInsert(context, item);
|
||||
|
||||
+1
-1
@@ -31,8 +31,8 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> {
|
||||
public static final InsertHandler<JavaPsiClassReferenceElement> JAVA_CLASS_INSERT_HANDLER = new InsertHandler<JavaPsiClassReferenceElement>() {
|
||||
public void handleInsert(final InsertionContext context, final JavaPsiClassReferenceElement item) {
|
||||
if (completingRawConstructor(context, item)) {
|
||||
DefaultInsertHandler.NO_TAIL_PARENS_HANDLER.handleInsert(context, item);
|
||||
ConstructorInsertHandler.insertParentheses(context, item, item.getObject());
|
||||
DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), item);
|
||||
} else {
|
||||
new DefaultInsertHandler().handleInsert(context, item);
|
||||
}
|
||||
|
||||
-2
@@ -174,7 +174,6 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
JavaCompletionUtil.setShowFQN((LookupItem)item);
|
||||
} else {
|
||||
}
|
||||
((LookupItem) item).setInsertHandler(DefaultInsertHandler.NO_TAIL_PARENS_HANDLER);
|
||||
result.addElement(decorate(LookupElementDecorator.withInsertHandler((LookupItem)item, ConstructorInsertHandler.INSTANCE), infos));
|
||||
}
|
||||
}
|
||||
@@ -578,7 +577,6 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
item.setAttribute(LookupItem.INDICATE_ANONYMOUS, "");
|
||||
}
|
||||
|
||||
item.setInsertHandler(DefaultInsertHandler.NO_TAIL_PARENS_HANDLER);
|
||||
result.addElement(decorate(type instanceof PsiClassType ? LookupElementDecorator.withInsertHandler(item, ConstructorInsertHandler.INSTANCE) : item, infos));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user