@@ -108,8 +108,11 @@ public CsvColumnInfoMap<PsiElement> getColumnInfoMap() {
108108 }
109109
110110 public boolean hasErrors () {
111+ if (!isValid ()) {
112+ return true ;
113+ }
111114 CsvColumnInfoMap columnInfoMap = getColumnInfoMap ();
112- return ! isValid () || (columnInfoMap != null && columnInfoMap .hasErrors ());
115+ return (columnInfoMap != null && columnInfoMap .hasErrors ());
113116 }
114117
115118 protected Object [][] storeStateChange (Object [][] data ) {
@@ -129,7 +132,8 @@ public void saveChanges(final String content) {
129132 return ;
130133 }
131134 ApplicationManager .getApplication ().invokeLater (() -> {
132- if (!this .document .isWritable () && ReadonlyStatusHandler .getInstance (this .project ).ensureFilesWritable (this .file ).hasReadonlyFiles ()) {
135+ if (project == null || project .isDisposed () ||
136+ (!this .document .isWritable () && ReadonlyStatusHandler .getInstance (this .project ).ensureFilesWritable (this .file ).hasReadonlyFiles ())) {
133137 return ;
134138 }
135139 ApplicationManager .getApplication ().runWriteAction (() ->
@@ -206,6 +210,9 @@ public boolean isModified() {
206210
207211 @ Override
208212 public boolean isValid () {
213+ if (file == null || !file .isValid ()) {
214+ return false ;
215+ }
209216 CsvFile csvFile = this .getCsvFile ();
210217 return csvFile != null && csvFile .isValid ();
211218 }
@@ -277,7 +284,7 @@ public int compareTo(@NotNull FileEditorLocation o) {
277284
278285 @ Nullable
279286 public StructureViewBuilder getStructureViewBuilder () {
280- return file != null && file . isValid () ? StructureViewBuilder .PROVIDER .getStructureViewBuilder (file .getFileType (), file , this .project ) : null ;
287+ return isValid () ? StructureViewBuilder .PROVIDER .getStructureViewBuilder (file .getFileType (), file , this .project ) : null ;
281288 }
282289
283290 @ Nullable
@@ -292,6 +299,9 @@ public Project getProject() {
292299
293300 @ Nullable
294301 public final CsvFile getCsvFile () {
302+ if (project == null || project .isDisposed ()) {
303+ return null ;
304+ }
295305 if (this .psiFile == null || !this .psiFile .isValid ()) {
296306 this .document = FileDocumentManager .getInstance ().getDocument (this .file );
297307 PsiDocumentManager documentManager = PsiDocumentManager .getInstance (project );
0 commit comments