コード例 #1
0
  public void navigateIn(@NotNull Editor e) {
    final int offset = getOffset();
    CaretModel caretModel = e.getCaretModel();
    boolean caretMoved = false;
    if (myLogicalLine >= 0) {
      LogicalPosition pos = new LogicalPosition(myLogicalLine, Math.max(myLogicalColumn, 0));
      if (offset < 0 || offset == e.logicalPositionToOffset(pos)) {
        caretModel.moveToLogicalPosition(pos);
        caretMoved = true;
      }
    }
    if (!caretMoved && offset >= 0) {
      caretModel.moveToOffset(Math.min(offset, e.getDocument().getTextLength()));
      caretMoved = true;
    }

    if (caretMoved) {
      e.getSelectionModel().removeSelection();
      scrollToCaret(e);
      unfoldCurrentLine(e);
    }
  }
コード例 #2
0
  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;
    }
  }