@Override public void updateParameterInfo( @NotNull JetValueArgumentList argumentList, @NotNull UpdateParameterInfoContext context) { if (context.getParameterOwner() != argumentList) context.removeHint(); int offset = context.getOffset(); ASTNode child = argumentList.getNode().getFirstChildNode(); int i = 0; while (child != null && child.getStartOffset() < offset) { if (child.getElementType() == JetTokens.COMMA) ++i; child = child.getTreeNext(); } context.setCurrentParameter(i); }
private static JetValueArgumentList findCallAndUpdateContext(UpdateParameterInfoContext context) { PsiFile file = context.getFile(); PsiElement element = file.findElementAt(context.getOffset()); if (element == null) return null; PsiElement parent = element.getParent(); while (parent != null && !(parent instanceof JetValueArgumentList)) { element = element.getParent(); parent = parent.getParent(); } if (parent == null) return null; JetValueArgumentList argumentList = (JetValueArgumentList) parent; if (element instanceof JetValueArgument) { JetValueArgument arg = (JetValueArgument) element; int i = argumentList.getArguments().indexOf(arg); context.setCurrentParameter(i); context.setHighlightedParameter(arg); } return argumentList; }