mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java completion argument live templates: add yet another registry key to autopopup completion
This commit is contained in:
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.completion.util.MethodParenthesesHandler;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInsight.lookup.impl.JavaElementLookupRenderer;
|
||||
import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.codeInsight.template.impl.ConstantNode;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
@@ -206,7 +206,8 @@ public class JavaMethodCallElement extends LookupItem<PsiMethod> implements Type
|
||||
template.addTextSegment(", ");
|
||||
}
|
||||
String name = StringUtil.notNullize(parameters[i].getName());
|
||||
template.addVariable(name, new ConstantNode(name), new ConstantNode(name), true);
|
||||
Expression expression = Registry.is("java.completion.argument.live.template.completion") ? new AutoPopupCompletion() : new ConstantNode(name);
|
||||
template.addVariable(name, expression, new ConstantNode(name), true);
|
||||
}
|
||||
template.addTextSegment(argList.getText().substring(caretOffset - argRange.getStartOffset(), argList.getTextLength()));
|
||||
template.addEndVariable();
|
||||
@@ -353,4 +354,24 @@ public class JavaMethodCallElement extends LookupItem<PsiMethod> implements Type
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class AutoPopupCompletion extends Expression {
|
||||
@Nullable
|
||||
@Override
|
||||
public Result calculateResult(ExpressionContext context) {
|
||||
return new InvokeActionResult(() -> AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LookupElement[] calculateLookupItems(ExpressionContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +329,9 @@ java.completion.make.outer.variables.final.description=Make variables accessed f
|
||||
java.completion.argument.live.template=false
|
||||
java.completion.argument.live.template.description=When completing a method call, start a live template with all arguments
|
||||
|
||||
java.completion.argument.live.template.completion=false
|
||||
java.completion.argument.live.template.completion.description=If java.completion.argument.live.template is enabled, show completion for method arguments immediately
|
||||
|
||||
java.completion.show.constructors=false
|
||||
java.completion.show.constructors.description=Show separate constructors when completing constructor call, instead of a single class name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user