Search in sources :

Example 1 with JsonSchemaAnnotator

use of com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator in project intellij-community by JetBrains.

the class JsonSchemaHighlightingTest method testImpl.

private void testImpl(@NotNull final String schema, @NotNull final String text) throws Exception {
    final PsiFile file = createFile(myModule, "config.json", text);
    final Annotator annotator = new JsonSchemaAnnotator();
    registerProvider(getProject(), schema);
    LanguageAnnotators.INSTANCE.addExplicitExtension(JsonLanguage.INSTANCE, annotator);
    Disposer.register(getTestRootDisposable(), new Disposable() {

        @Override
        public void dispose() {
            LanguageAnnotators.INSTANCE.removeExplicitExtension(JsonLanguage.INSTANCE, annotator);
            JsonSchemaTestServiceImpl.setProvider(null);
        }
    });
    configureByFile(file.getVirtualFile());
    doTest(file.getVirtualFile(), true, false);
}
Also used : Disposable(com.intellij.openapi.Disposable) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) Annotator(com.intellij.lang.annotation.Annotator) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) PsiFile(com.intellij.psi.PsiFile)

Example 2 with JsonSchemaAnnotator

use of com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator in project intellij-community by JetBrains.

the class JsonSchemaReadTest method testMainSchemaHighlighting.

public void testMainSchemaHighlighting() throws Exception {
    final Set<VirtualFile> files = JsonSchemaServiceEx.Impl.getEx(myProject).getSchemaFiles();
    VirtualFile mainSchema = null;
    for (VirtualFile file : files) {
        if ("schema.json".equals(file.getName())) {
            mainSchema = file;
            break;
        }
    }
    assertNotNull(mainSchema);
    assertTrue(JsonSchemaFileType.INSTANCE.equals(mainSchema.getFileType()));
    final Annotator annotator = new JsonSchemaAnnotator();
    LanguageAnnotators.INSTANCE.addExplicitExtension(JsonLanguage.INSTANCE, annotator);
    Disposer.register(getTestRootDisposable(), new Disposable() {

        @Override
        public void dispose() {
            LanguageAnnotators.INSTANCE.removeExplicitExtension(JsonLanguage.INSTANCE, annotator);
            JsonSchemaTestServiceImpl.setProvider(null);
        }
    });
    configureByExistingFile(mainSchema);
    final List<HighlightInfo> infos = doHighlighting();
    for (HighlightInfo info : infos) {
        if (!HighlightSeverity.INFORMATION.equals(info.getSeverity()))
            assertFalse(info.getDescription(), true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) Annotator(com.intellij.lang.annotation.Annotator) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) JsonSchemaAnnotator(com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo)

Aggregations

Annotator (com.intellij.lang.annotation.Annotator)2 Disposable (com.intellij.openapi.Disposable)2 JsonSchemaAnnotator (com.jetbrains.jsonSchema.ide.JsonSchemaAnnotator)2 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1