Integer (@NotNull Project project, @NotNull VirtualFile file, @Nullable Editor contextEditor) { Editor editor = null; if (contextEditor != null) { VirtualFile contextFile = FileDocumentManager.getInstance().getFile(contextEditor.getDocument()); if (Comparing.equal(contextFile, file)) editor = contextEditor; } if (editor == null) { FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(file); if (fileEditor instanceof TextEditor) editor = ((TextEditor)fileEditor).getEditor(); } if (editor == null) return null; return editor.getCaretModel().getLogicalPosition().line; }