XSourcePositionImpl (@Nullable VirtualFile file, final int line, final int column) { if (file == null) { return null; } return new XSourcePositionImpl(file) { private final NotNullLazyValue<Integer> myOffset = NotNullLazyValue.atomicLazy(() -> { return ReadAction.compute(() -> { int offset; if (file instanceof LightVirtualFile || file instanceof HttpVirtualFile) { return -1; } else { Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null) { return -1; } int l = Math.max(0, line); int c = Math.max(0, column); offset = l < document.getLineCount() ? document.getLineStartOffset(l) + c : -1; if (offset >= document.getTextLength()) { offset = document.getTextLength() - 1; } } return offset; }); }); @Override public int getLine() { return line; } @Override public int getOffset() { return myOffset.getValue(); } }; }