void (@NotNull PsiElement node, @NotNull ReplaceOptions options, @NotNull ReplacementBuilder builder) { node.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { visitElement(expression); } @Override public void visitNameValuePair(@NotNull PsiNameValuePair pair) { super.visitNameValuePair(pair); setParameterContext(pair, pair.getNameIdentifier(), pair.getValue()); } @Override public void visitParameter(@NotNull PsiParameter parameter) { final PsiElement scope = parameter.getDeclarationScope(); if (scope instanceof PsiCatchSection || scope instanceof PsiForeachStatement) { return; } setParameterContext(parameter, parameter.getNameIdentifier(), parameter.getTypeElement()); } private void setParameterContext(@NotNull PsiElement element, PsiElement nameIdentifier, @Nullable PsiElement scopeElement) { final ParameterInfo nameInfo = builder.findParameterization(nameIdentifier); if (nameInfo == null) return; nameInfo.setArgumentContext(false); final Map<String, ParameterInfo> infos = new HashMap<>(); infos.put(nameInfo.getName(), nameInfo); nameInfo.putUserData(PARAMETER_CONTEXT, infos); nameInfo.setElement(element); if (scopeElement == null) return; scopeElement.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { final String type = element.getText(); if (MatchUtil.isTypedVariable(type)) { final ParameterInfo typeInfo = builder.findParameterization(element); if (typeInfo != null) { typeInfo.setArgumentContext(false); typeInfo.putUserData(PARAMETER_CONTEXT, Collections.emptyMap()); infos.put(typeInfo.getName(), typeInfo); return; } } super.visitElement(element); } }); final int length = element.getTextLength() - infos.keySet().stream().mapToInt(key -> key.length() + 2).sum(); nameInfo.putUserData(PARAMETER_LENGTH, length); } }); }