mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
minor
This commit is contained in:
+13
-4
@@ -17,7 +17,6 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -33,7 +32,13 @@ import java.util.List;
|
||||
*/
|
||||
class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<LookupItem>> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.ConstructorInsertHandler");
|
||||
public static final ConstructorInsertHandler INSTANCE = new ConstructorInsertHandler();
|
||||
public static final ConstructorInsertHandler SMART_INSTANCE = new ConstructorInsertHandler(true);
|
||||
public static final ConstructorInsertHandler BASIC_INSTANCE = new ConstructorInsertHandler(false);
|
||||
private final boolean mySmart;
|
||||
|
||||
private ConstructorInsertHandler(boolean smart) {
|
||||
mySmart = smart;
|
||||
}
|
||||
|
||||
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupItem> item) {
|
||||
@SuppressWarnings({"unchecked"}) final LookupItem<PsiClass> delegate = item.getDelegate();
|
||||
@@ -50,7 +55,9 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
|
||||
|
||||
if (item.getUserData(LookupItem.BRACKETS_COUNT_ATTR) == null && !inAnonymous) {
|
||||
if (((PsiClass)item.getObject()).hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.anonymous");
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.anonymous");
|
||||
}
|
||||
|
||||
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
|
||||
|
||||
@@ -69,7 +76,9 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
|
||||
CodeStyleManager.getInstance(context.getProject()).reformat(classReference);
|
||||
}
|
||||
}
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.afternew");
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.afternew");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -164,7 +164,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
final List<ExpectedTypeInfo> infos = Arrays.asList(getExpectedTypes(parameters));
|
||||
for (final LookupElement item : completeReference(element, reference, filter, true, parameters)) {
|
||||
if (item.getObject() instanceof PsiClass) {
|
||||
result.addElement(decorate(LookupElementDecorator.withInsertHandler((LookupItem)item, ConstructorInsertHandler.INSTANCE), infos));
|
||||
result.addElement(decorate(LookupElementDecorator.withInsertHandler((LookupItem)item, ConstructorInsertHandler.SMART_INSTANCE), infos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -530,7 +530,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
item.setAttribute(LookupItem.INDICATE_ANONYMOUS, "");
|
||||
}
|
||||
|
||||
result.addElement(decorate(type instanceof PsiClassType ? LookupElementDecorator.withInsertHandler(item, ConstructorInsertHandler.INSTANCE) : item, infos));
|
||||
result.addElement(decorate(type instanceof PsiClassType ? LookupElementDecorator.withInsertHandler(item, ConstructorInsertHandler.SMART_INSTANCE) : item, infos));
|
||||
}
|
||||
|
||||
static Set<LookupElement> completeReference(final PsiElement element, PsiReference reference, final ElementFilter filter, final boolean acceptClasses, CompletionParameters parameters) {
|
||||
@@ -541,7 +541,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
|
||||
if (reference instanceof PsiJavaReference) {
|
||||
final PsiJavaReference javaReference = (PsiJavaReference)reference;
|
||||
|
||||
return JavaCompletionUtil.processJavaReference(element, javaReference, new ElementFilter() {
|
||||
return JavaCompletionUtil.processJavaReference(element, javaReference, new ElementFilter() {
|
||||
public boolean isAcceptable(Object element, PsiElement context) {
|
||||
return filter.isAcceptable(element, context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user