Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove use of internal API #693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
Loading