private static void patchLeaves(@NotNull List<? extends PlaceInfo> placeInfos,
                                  @NotNull InjectedFileViewProvider viewProvider,
                                  @NotNull ASTNode parsedNode,
                                  @NotNull CharSequence documentText) throws PatchException {
    Runnable patch = () -> {
      LeafPatcher patcher = new LeafPatcher(placeInfos, parsedNode.getTextLength());
      patcher.patch(parsedNode, placeInfos);
    };
    if (viewProvider instanceof SingleRootInjectedFileViewProvider) {
      ((SingleRootInjectedFileViewProvider)viewProvider).doNotInterruptMeWhileImPatchingLeaves(patch);
    } else if (viewProvider instanceof MultipleRootsInjectedFileViewProvider) {
      ((MultipleRootsInjectedFileViewProvider)viewProvider).doNotInterruptMeWhileImPatchingLeaves(patch);
    }
    if (!((FileElement)parsedNode).textMatches(documentText)) {
      throw new PatchException("After patch: doc:\n'" + documentText + "'\n---PSI:\n'" + parsedNode.getText());
    }
  }
private static void patchLeaves(@NotNull List<? extends PlaceInfo> placeInfos,
                                  @NotNull InjectedFileViewProvider viewProvider,
                                  @NotNull ASTNode parsedNode,
                                  @NotNull CharSequence documentText)