Skip to content

Commit

Permalink
fix: remove use of internal API
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Dec 12, 2024
1 parent fb555b2 commit 4d9d652
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 4d9d652

Please sign in to comment.