public OpenEditorTracker startTracking() {
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
@Override public void projectOpened(final Project project) {
MessageBusConnection connection = project.getMessageBus().connect();
connection.subscribe(FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
VirtualFile virtualFile = event.getNewFile();
if (virtualFile == null) return;