void (@NotNull FileEditorManagerEvent e) { if (!clientId.equals(ClientId.getCurrent())) return; VirtualFile file = e.getNewFile(); final PsiFile psiFile = file != null && file.isValid() ? PsiManager.getInstance(myProject).findFile(file) : null; // This invokeLater is required. The problem is setFile does a commit to PSI, but setFile is // invoked inside PSI change event. It causes an Exception like "Changes to PSI are not allowed inside event processing" ApplicationManager.getApplication().invokeLater(() -> setFile(psiFile, false)); }