PyMethodDescriptor (final PyFunction function) { return new PyMethodDescriptor(function) { @Override public @NotNull List<PyParameterInfo> getParameters() { final List<PyParameterInfo> result = new ArrayList<>(); final List<PyParameterInfo> originalParams = super.getParameters(); final PeekingIterator<Pair<Integer, PyParameterInfo>> extra = Iterators.peekingIterator(myExtraParameters.iterator()); while (extra.hasNext() && extra.peek().getFirst() < 0) { result.add(extra.next().getSecond()); } for (int i = 0; i < originalParams.size(); i++) { result.add(originalParams.get(i)); while (extra.hasNext() && extra.peek().getFirst() == i) { result.add(extra.next().getSecond()); } } return result; } }; }