private OpenFileDescriptor(
      @NotNull Project project,
      @NotNull VirtualFile file,
      int logicalLine,
      int logicalColumn,
      int offset,
      boolean persistent) {
    myProject = project;

    myFile = file;
    myLogicalLine = logicalLine;
    myLogicalColumn = logicalColumn;
    myOffset = offset;
    if (offset >= 0) {
      myRangeMarker = LazyRangeMarkerFactory.getInstance(project).createRangeMarker(file, offset);
    } else if (logicalLine >= 0) {
      myRangeMarker =
          LazyRangeMarkerFactory.getInstance(project)
              .createRangeMarker(file, logicalLine, Math.max(0, logicalColumn), persistent);
    } else {
      myRangeMarker = null;
    }
  }
  public void testLazyRangeMarkers() {
    psiFile = createFile("x.txt", "xxx");

    LazyRangeMarkerFactoryImpl factory =
        (LazyRangeMarkerFactoryImpl) LazyRangeMarkerFactory.getInstance(getProject());
    VirtualFile virtualFile = psiFile.getVirtualFile();
    LazyRangeMarkerFactoryImpl.LazyMarker marker =
        (LazyRangeMarkerFactoryImpl.LazyMarker) factory.createRangeMarker(virtualFile, 0);
    WeakList<LazyRangeMarkerFactoryImpl.LazyMarker> markers =
        LazyRangeMarkerFactoryImpl.getMarkers(virtualFile);
    assertSame(marker, assertOneElement(markers));

    assertFalse(marker.isDelegated());
    assertTrue(marker.isValid());
    assertEquals(0, marker.getStartOffset());
    assertFalse(marker.isDelegated());

    marker.dispose();
    assertFalse(marker.isValid());
    assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile));

    marker = (LazyRangeMarkerFactoryImpl.LazyMarker) factory.createRangeMarker(virtualFile, 0);
    assertFalse(marker.isDelegated());
    assertTrue(marker.isValid());
    assertEquals(0, marker.getStartOffset());
    assertFalse(marker.isDelegated());

    Document document = marker.getDocument();
    document.insertString(2, "yyy");
    assertTrue(marker.isDelegated());
    assertTrue(marker.isValid());
    assertEquals(0, marker.getStartOffset());

    assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile));
    marker.dispose();
    assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile));
  }