private void runAnnotators(PsiElement element) { List<Annotator> annotators = cachedAnnotators.get(element.getLanguage().getID()); if (annotators.isEmpty()) return; final boolean dumb = myDumbService.isDumb(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < annotators.size(); i++) { Annotator annotator = annotators.get(i); if (dumb && !DumbService.isDumbAware(annotator)) { continue; } ProgressManager.checkCanceled(); annotator.annotate(element, myAnnotationHolder); } }
public void testInfoTestAttributes() throws Exception { LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>(); extension.language="TEXT"; extension.implementationClass = TestAnnotator.class.getName(); PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, 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(); assertEquals(1, highlighters.length); TextAttributes attributes = highlighters[0].getTextAttributes(); assertNotNull(attributes); assertNull(attributes.getBackgroundColor()); assertNull(attributes.getForegroundColor()); }
private void runAnnotators(PsiElement element) { List<Annotator> annotators = cachedAnnotators.get(element.getLanguage()); if (annotators.isEmpty()) return; final boolean dumb = myDumbService.isDumb(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < annotators.size(); i++) { Annotator annotator = annotators.get(i); if (dumb && !DumbService.isDumbAware(annotator)) { continue; } ProgressManager.checkCanceled(); annotator.annotate(element, myAnnotationHolder); } }
private void runAnnotators(PsiElement element) { List<Annotator> annotators = myCachedAnnotators.get(element.getLanguage().getID()); if (annotators.isEmpty()) return; final boolean dumb = myDumbService.isDumb(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < annotators.size(); i++) { Annotator annotator = annotators.get(i); if (dumb && !DumbService.isDumbAware(annotator)) { continue; } ProgressManager.checkCanceled(); annotator.annotate(element, myAnnotationHolder); } }
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); } }
@NotNull private AnnotationHolderImpl getAnnotationsAtCaret(String filename, String content) { PsiFile psiFile = myFixture.configureByText(filename, content); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile)); for (Annotator annotator : LanguageAnnotators.INSTANCE.allForLanguage(psiFile.getLanguage())) { annotator.annotate(psiElement, annotations); } return annotations; }
public void testAnnotator() throws Exception { Annotator annotator = new MyAnnotator(); Language javaLanguage = JavaFileType.INSTANCE.getLanguage(); LanguageAnnotators.INSTANCE.addExplicitExtension(javaLanguage, annotator); enableInspectionTool(new DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection()); try { doAllTests(); } finally { LanguageAnnotators.INSTANCE.removeExplicitExtension(javaLanguage, annotator); } }
@NotNull @Override public Collection<Annotator> initialValue(@NotNull String languageId) { Language language = Language.findLanguageByID(languageId); return language == null ? ContainerUtil.<Annotator>emptyList() : LanguageAnnotators.INSTANCE.allForLanguage(language); }
@Override public void extensionAdded(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { cachedAnnotators.clear(); }
@Override public void extensionRemoved(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { cachedAnnotators.clear(); }
@NotNull @Override public Collection<Annotator> initialValue(@NotNull Language key) { return LanguageAnnotators.INSTANCE.allForLanguage(key); }
@Nonnull @Override public Collection<Annotator> initialValue(@Nonnull String languageId) { Language language = Language.findLanguageByID(languageId); return language == null ? ContainerUtil.<Annotator>emptyList() : LanguageAnnotators.INSTANCE.allForLanguage(language); }
@Nonnull List<Annotator> get(@Nonnull String languageId) { return cachedAnnotators.get(languageId); }