diff --git a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileProvider.java b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileProvider.java index b735468f8..9521962cd 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileProvider.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileProvider.java @@ -13,14 +13,8 @@ *******************************************************************************/ package com.redhat.devtools.lsp4ij.settings.jsonSchema; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.impl.PsiManagerEx; -import com.intellij.psi.impl.file.impl.FileManagerImpl; -import com.intellij.util.ModalityUiUtil; import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider; import com.jetbrains.jsonSchema.extension.SchemaType; import com.jetbrains.jsonSchema.impl.JsonSchemaVersion; @@ -70,13 +64,9 @@ public boolean isUserVisible() { return false; } - protected static void reloadPsi(@NotNull VirtualFile file, - @NotNull Project project) { - final FileManagerImpl fileManager = (FileManagerImpl) PsiManagerEx.getInstanceEx(project).getFileManager(); - if (fileManager.findCachedViewProvider(file) != null) { - ModalityUiUtil.invokeLaterIfNeeded(ModalityState.defaultModalityState(), project.getDisposed(), - () -> WriteAction.run(() -> fileManager.forceReload(file)) - ); + protected static void reloadPsi(@NotNull VirtualFile file) { + if (file != null) { + file.refresh(true, false, () -> file.refresh(false, false)); } } } diff --git a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileSystemProvider.java b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileSystemProvider.java index 5e9f94fe5..19b2c2349 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileSystemProvider.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/AbstractLSPJsonSchemaFileSystemProvider.java @@ -41,9 +41,7 @@ public final VirtualFile getSchemaFile() { String jsonSchemaFileUrl = jsonSchemaUrl != null ? VfsUtil.convertFromUrl(jsonSchemaUrl) : null; jsonSchemaFile = jsonSchemaFileUrl != null ? VirtualFileManager.getInstance().findFileByUrl(jsonSchemaFileUrl) : null; // Make sure that the IDE is using the absolute latest version of the JSON schema - if (jsonSchemaFile != null) { - jsonSchemaFile.refresh(true, false, () -> jsonSchemaFile.refresh(false, false)); - } + reloadPsi(jsonSchemaFile); } return jsonSchemaFile; } diff --git a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/LSPServerConfigurationJsonSchemaFileProvider.java b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/LSPServerConfigurationJsonSchemaFileProvider.java index 9fb61341e..58dda9d8e 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/LSPServerConfigurationJsonSchemaFileProvider.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/settings/jsonSchema/LSPServerConfigurationJsonSchemaFileProvider.java @@ -116,7 +116,7 @@ private static void updateFileContent(@NotNull String content, // Update the virtual file content and the modification stamp (used by Json Schema cache) file.setContent(content); // Synchronize the Psi file from the new content of the virtual file and the modification stamp (used by Json Schema cache) - reloadPsi(file, project); + reloadPsi(file); } }