use of com.intellij.lang.annotation.Annotator in project intellij-community by JetBrains.
the class FixAllAnnotatorQuickfixTest method testAnnotator.
public void testAnnotator() throws Exception {
Annotator annotator = new MyAnnotator();
Language javaLanguage = StdFileTypes.JAVA.getLanguage();
LanguageAnnotators.INSTANCE.addExplicitExtension(javaLanguage, annotator);
enableInspectionTool(new DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection());
try {
doAllTests();
} finally {
LanguageAnnotators.INSTANCE.removeExplicitExtension(javaLanguage, annotator);
}
}
use of com.intellij.lang.annotation.Annotator in project intellij-community by JetBrains.
the class LightAdvHighlightingTest method testInjectedAnnotator.
public void testInjectedAnnotator() {
Annotator annotator = new MyAnnotator();
Language xml = StdFileTypes.XML.getLanguage();
LanguageAnnotators.INSTANCE.addExplicitExtension(xml, annotator);
try {
List<Annotator> list = LanguageAnnotators.INSTANCE.allForLanguage(xml);
assertTrue(list.toString(), list.contains(annotator));
doTest(BASE_PATH + "/" + getTestName(false) + ".xml", true, false);
} finally {
LanguageAnnotators.INSTANCE.removeExplicitExtension(xml, annotator);
}
List<Annotator> list = LanguageAnnotators.INSTANCE.allForLanguage(xml);
assertFalse(list.toString(), list.contains(annotator));
}
use of com.intellij.lang.annotation.Annotator in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testAddRemoveHighlighterRaceInIncorrectAnnotatorsWhichUseFileRecursiveVisit.
public void testAddRemoveHighlighterRaceInIncorrectAnnotatorsWhichUseFileRecursiveVisit() throws Exception {
Annotator annotator = new MyIncorrectlyRecursiveAnnotator();
com.intellij.lang.Language java = StdFileTypes.JAVA.getLanguage();
LanguageAnnotators.INSTANCE.addExplicitExtension(java, annotator);
try {
List<Annotator> list = LanguageAnnotators.INSTANCE.allForLanguage(java);
assertTrue(list.toString(), list.contains(annotator));
configureByText(StdFileTypes.JAVA, "class X {\n" + " int foo(Object param) {\n" + " if (param == this) return 1;\n" + " return 0;\n" + " }\n" + "}\n");
((EditorImpl) myEditor).getScrollPane().getViewport().setSize(1000, 1000);
assertEquals(getFile().getTextRange(), VisibleHighlightingPassFactory.calculateVisibleRange(getEditor()));
assertEquals("XXX", assertOneElement(doHighlighting(HighlightSeverity.WARNING)).getDescription());
for (int i = 0; i < 100; i++) {
//System.out.println("i = " + i);
DaemonCodeAnalyzer.getInstance(getProject()).restart();
List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING);
assertEquals("XXX", assertOneElement(infos).getDescription());
}
} finally {
LanguageAnnotators.INSTANCE.removeExplicitExtension(java, annotator);
}
List<Annotator> list = LanguageAnnotators.INSTANCE.allForLanguage(java);
assertFalse(list.toString(), list.contains(annotator));
}
use of com.intellij.lang.annotation.Annotator 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);
}
use of com.intellij.lang.annotation.Annotator in project intellij-community by JetBrains.
the class DocumentMarkupModelTest method testInfoTestAttributes.
public void testInfoTestAttributes() throws Exception {
LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<>();
extension.language = "TEXT";
extension.implementationClass = TestAnnotator.class.getName();
PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, myFixture.getTestRootDisposable());
myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()) {
{
initFonts();
}
};
scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
((EditorEx) myFixture.getEditor()).setColorsScheme(scheme);
myFixture.doHighlighting();
MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
RangeHighlighter[] highlighters = model.getAllHighlighters();
assertThat(highlighters).hasSize(1);
TextAttributes attributes = highlighters[0].getTextAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.getBackgroundColor()).isNull();
assertThat(attributes.getForegroundColor()).isNull();
}
Aggregations