caret position and round brackets for function call completion?
What is the correct way to implement completion for function calls, so that the caret ends up in the round brackets of the call? I.e.
base<caret_where_autocompletion_is_invoked> -> basename(<caret>)
Also it's not so clear where the round brackets of the call should come from. Should they be part of the lookup item or is there a more clever way to finetune the actual insertion code for an autocompletion option?
Currently I'm using
LookupElementBuilder.create(lookupObject, funName).withTypeText(pckg)
with a custom com.intellij.psi.impl.light.LightElement implementation for `lookupObject` to provide documentation for completion options. See https://github.com/holgerbrandl/r4intellij/blob/master/src/com/r4intellij/psi/references/RReferenceImpl.java#L187
Thanks in advance,
Holger Brandl
Please sign in to leave a comment.
Please try LookupElementBuilder#withInsertHandler, where you can add the parentheses and put the caret inside. If you only need this functionality, you can consider reusing ParenthesesInsertHandler#WITH_PARAMETERS.