use of com.jetbrains.jsonSchema.ide.JsonSchemaService in project intellij-community by JetBrains.
the class JsonSchemaConfigurable method doValidation.
private void doValidation() throws ConfigurationException {
final File file = new File(myProject.getBasePath(), myView.getSchemaSubPath());
VirtualFile vFile = null;
if (!file.exists() || (vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)) == null) {
throw new ConfigurationException((!StringUtil.isEmptyOrSpaces(myDisplayName) ? (myDisplayName + ": ") : "") + "Schema file does not exist");
}
final String filename = file.getName();
if (StringUtil.isEmptyOrSpaces(myDisplayName))
throw new ConfigurationException(filename + ": Schema name is empty");
if (StringUtil.isEmptyOrSpaces(myView.getSchemaSubPath()))
throw new ConfigurationException(filename + ": Schema path is empty");
final CollectConsumer<String> collectConsumer = new CollectConsumer<>();
final JsonSchemaService service = JsonSchemaService.Impl.get(myProject);
if (service != null && !service.isSchemaFile(vFile, collectConsumer)) {
final String message;
if (collectConsumer.getResult().isEmpty())
message = filename + ": Can not read JSON schema from file (Unknown reason)";
else
message = filename + ": Can not read JSON schema from file: " + StringUtil.join(collectConsumer.getResult(), "; ");
logErrorForUser(message);
throw new RuntimeConfigurationWarning(message);
}
}
use of com.jetbrains.jsonSchema.ide.JsonSchemaService in project intellij-community by JetBrains.
the class JsonSchemaMappingsConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
final List<JsonSchemaMappingsConfigurationBase.SchemaInfo> uiList = getUiList(true);
validate(uiList);
final Map<String, JsonSchemaMappingsConfigurationBase.SchemaInfo> projectMap = new HashMap<>();
for (JsonSchemaMappingsConfigurationBase.SchemaInfo info : uiList) {
if (!info.isApplicationLevel()) {
projectMap.put(info.getName(), info);
}
}
if (myProject != null) {
JsonSchemaMappingsProjectConfiguration.getInstance(myProject).setState(projectMap);
}
final Project[] projects = ProjectManager.getInstance().getOpenProjects();
for (Project project : projects) {
final JsonSchemaService service = JsonSchemaService.Impl.get(project);
if (service != null)
service.reset();
}
if (myProject != null) {
DaemonCodeAnalyzer.getInstance(myProject).restart();
EditorNotifications.getInstance(myProject).updateAllNotifications();
}
}
Aggregations