use of com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider in project intellij-community by JetBrains.
the class JsonSchemaServiceImpl method ensureSchemaFiles.
private void ensureSchemaFiles() {
synchronized (myLock) {
if (!initialized) {
for (JsonSchemaFileProvider provider : getProviders()) {
final VirtualFile schemaFile = provider.getSchemaFile();
if (schemaFile != null) {
mySchemaFiles.add(schemaFile);
// this will make it refresh
myDefinitions.dropKey(schemaFile);
myWrappers.remove(schemaFile);
}
}
initialized = true;
}
}
}
use of com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider in project intellij-community by JetBrains.
the class JsonSchemaServiceImpl method getProviders.
private List<JsonSchemaFileProvider> getProviders() {
final List<JsonSchemaFileProvider> providers = new ArrayList<>();
for (JsonSchemaProviderFactory factory : getProviderFactories()) {
providers.addAll(factory.getProviders(myProject));
}
Collections.sort(providers, FILE_PROVIDER_COMPARATOR);
return providers;
}
use of com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider in project intellij-community by JetBrains.
the class JsonSchemaServiceImpl method getWrapperSkeletonMethod.
private void getWrapperSkeletonMethod(@NotNull final Processor<JsonSchemaFileProvider> processor, @NotNull final Consumer<CodeInsightProviders> consumer, final boolean multiple) {
final List<JsonSchemaFileProvider> filtered = getProviders().stream().filter(processor::process).collect(Collectors.toList());
if (filtered.isEmpty())
return;
final List<JsonSchemaFileProvider> matchingProviders = new SmartList<>();
synchronized (myLock) {
for (JsonSchemaFileProvider provider : filtered) {
final CodeInsightProviders wrapper = myWrappers.get(provider.getSchemaFile());
if (wrapper != null) {
consumer.consume(wrapper);
if (!multiple)
return;
} else {
matchingProviders.add(provider);
if (!multiple)
break;
}
}
}
if (matchingProviders.isEmpty())
return;
final Map<VirtualFile, Pair<CodeInsightProviders, JsonSchemaFileProvider>> created = new HashMap<>();
for (JsonSchemaFileProvider provider : matchingProviders) {
// read action taken here => without wrapping lock
final CodeInsightProviders wrapper = createWrapper(provider);
if (wrapper != null)
created.put(provider.getSchemaFile(), Pair.create(wrapper, provider));
}
final List<JsonSchemaFileProvider> providers = getProviders();
synchronized (myLock) {
created.forEach((file, pair) -> {
final CodeInsightProviders wrapper = pair.getFirst();
final JsonSchemaFileProvider provider = pair.getSecond();
// check again, providers could have changed
if (!providers.contains(provider))
return;
// check again, rules could have changed
if (processor.process(provider)) {
myWrappers.putIfAbsent(file, wrapper);
consumer.consume(wrapper);
}
});
}
}
Aggregations