Collection<VirtualFile> (@NotNull VirtualFile file, boolean single, boolean onlyUserSchemas) { if (shouldIgnoreFile(file, myProject)) return Collections.emptyList(); String schemaUrl = null; if (!onlyUserSchemas) { // prefer schema-schema if it is specified in "$schema" property schemaUrl = JsonCachedValues.getSchemaUrlFromSchemaProperty(file, myProject); if (JsonFileResolver.isSchemaUrl(schemaUrl)) { final VirtualFile virtualFile = resolveFromSchemaProperty(schemaUrl, file); if (virtualFile != null) return Collections.singletonList(virtualFile); } } List<JsonSchemaFileProvider> providers = getProvidersForFile(file); // proper priority: // 1) user providers // 2) $schema property // 3) built-in providers // 4) schema catalog boolean checkSchemaProperty = true; if (!onlyUserSchemas && providers.stream().noneMatch(p -> p.getSchemaType() == SchemaType.userSchema)) { if (schemaUrl == null) schemaUrl = JsonCachedValues.getSchemaUrlFromSchemaProperty(file, myProject); if (schemaUrl == null) schemaUrl = JsonSchemaByCommentProvider.getCommentSchema(file, myProject); VirtualFile virtualFile = resolveFromSchemaProperty(schemaUrl, file); if (virtualFile != null) return Collections.singletonList(virtualFile); checkSchemaProperty = false; } if (!single) { List<VirtualFile> files = new ArrayList<>(); for (JsonSchemaFileProvider provider : providers) { VirtualFile schemaFile = getSchemaForProvider(myProject, provider); if (schemaFile != null) { files.add(schemaFile); } } if (!files.isEmpty()) { return files; } } else if (!providers.isEmpty()) { final JsonSchemaFileProvider selected; if (providers.size() > 2) return ContainerUtil.emptyList(); if (providers.size() > 1) { final Optional<JsonSchemaFileProvider> userSchema = providers.stream().filter(provider -> SchemaType.userSchema.equals(provider.getSchemaType())).findFirst(); if (userSchema.isEmpty()) return ContainerUtil.emptyList(); selected = userSchema.get(); } else selected = providers.get(0); VirtualFile schemaFile = getSchemaForProvider(myProject, selected); return ContainerUtil.createMaybeSingletonList(schemaFile); } if (onlyUserSchemas) { return ContainerUtil.emptyList(); } if (checkSchemaProperty) { if (schemaUrl == null) schemaUrl = JsonCachedValues.getSchemaUrlFromSchemaProperty(file, myProject); VirtualFile virtualFile = resolveFromSchemaProperty(schemaUrl, file); if (virtualFile != null) return Collections.singletonList(virtualFile); } VirtualFile schemaFromOtherSources = resolveSchemaFromOtherSources(file); if (schemaFromOtherSources != null) { return ContainerUtil.createMaybeSingletonList(schemaFromOtherSources); } PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); if (psiFile == null) { return Collections.emptyList(); } else { return ContainerUtil.createMaybeSingletonList(getDynamicSchemaForFile(psiFile)); } }