void () { final JsonSchemaService service = JsonSchemaService.Impl.get(getProject()); final List<JsonSchemaFileProvider> providers = new JsonSchemaProjectSelfProviderFactory().getProviders(getProject()); Assert.assertEquals(JsonSchemaProjectSelfProviderFactory.TOTAL_PROVIDERS, providers.size()); for (JsonSchemaFileProvider provider: providers) { final VirtualFile mainSchema = provider.getSchemaFile(); assertNotNull(mainSchema); assertTrue(service.isSchemaFile(mainSchema)); final PsiFile psi = PsiManager.getInstance(getProject()).findFile(mainSchema); Assert.assertNotNull(psi); Assert.assertTrue(psi instanceof JsonFile); final JsonValue top = ((JsonFile)psi).getTopLevelValue(); final JsonObject obj = ObjectUtils.tryCast(top, JsonObject.class); Assert.assertNotNull(obj); final JsonProperty properties = obj.findProperty("properties"); final JsonObject propObj = ObjectUtils.tryCast(properties.getValue(), JsonObject.class); final JsonProperty maxLength = propObj.findProperty("maxLength"); final JsonObject value = ObjectUtils.tryCast(maxLength.getValue(), JsonObject.class); Assert.assertNotNull(value); final JsonProperty ref = value.findProperty("$ref"); Assert.assertNotNull(ref); final JsonStringLiteral literal = ObjectUtils.tryCast(ref.getValue(), JsonStringLiteral.class); Assert.assertNotNull(literal); final PsiReference reference = psi.findReferenceAt(literal.getTextRange().getEndOffset() - 1); Assert.assertNotNull(reference); String positiveOrNonNegative = ((JsonSchemaProjectSelfProviderFactory.MyJsonSchemaFileProvider)provider).isSchemaV4() ? "positiveInteger" : "nonNegativeInteger"; Assert.assertEquals("#/definitions/" + positiveOrNonNegative, reference.getCanonicalText()); final PsiElement resolve = reference.resolve(); Assert.assertNotNull(resolve); Assert.assertTrue(StringUtil.equalsIgnoreWhitespaces(""" { "type": "integer", "minimum": 0 }""", resolve.getText())); Assert.assertTrue(resolve.getParent() instanceof JsonProperty); Assert.assertEquals(positiveOrNonNegative, ((JsonProperty)resolve.getParent()).getName()); } }