Java 类com.intellij.lang.annotation.Annotator 实例源码

项目:intellij-ce-playground    文件:DefaultHighlightVisitor.java   
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);
  }
}
项目:intellij-ce-playground    文件:DocumentMarkupModelTest.java   
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());
}
项目:tools-idea    文件:DefaultHighlightVisitor.java   
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);
  }
}
项目:consulo    文件:DefaultHighlightVisitor.java   
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);
  }
}
项目:intellij-ce-playground    文件:FixAllAnnotatorQuickfixTest.java   
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);
  }
}
项目:idea-php-shopware-plugin    文件:ShopwareLightCodeInsightFixtureTestCase.java   
@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;
}
项目:idea-php-drupal-symfony2-bridge    文件:DrupalLightCodeInsightFixtureTestCase.java   
@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;
}
项目:tools-idea    文件:FixAllAnnotatorQuickfixTest.java   
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);
  }
}
项目:idea-php-symfony2-plugin    文件:SymfonyLightCodeInsightFixtureTestCase.java   
@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;
}
项目:consulo-java    文件:FixAllAnnotatorQuickfixTest.java   
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);
  }
}
项目:intellij-ce-playground    文件:DefaultHighlightVisitor.java   
@NotNull
@Override
public Collection<Annotator> initialValue(@NotNull String languageId) {
  Language language = Language.findLanguageByID(languageId);
  return language == null ? ContainerUtil.<Annotator>emptyList() : LanguageAnnotators.INSTANCE.allForLanguage(language);
}
项目:intellij-ce-playground    文件:DefaultHighlightVisitor.java   
@Override
public void extensionAdded(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
  cachedAnnotators.clear();
}
项目:intellij-ce-playground    文件:DefaultHighlightVisitor.java   
@Override
public void extensionRemoved(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
  cachedAnnotators.clear();
}
项目:tools-idea    文件:DefaultHighlightVisitor.java   
@NotNull
@Override
public Collection<Annotator> initialValue(@NotNull Language key) {
  return LanguageAnnotators.INSTANCE.allForLanguage(key);
}
项目:tools-idea    文件:DefaultHighlightVisitor.java   
@Override
public void extensionAdded(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
  cachedAnnotators.clear();
}
项目:tools-idea    文件:DefaultHighlightVisitor.java   
@Override
public void extensionRemoved(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
  cachedAnnotators.clear();
}
项目:consulo    文件:CachedAnnotators.java   
@Nonnull
@Override
public Collection<Annotator> initialValue(@Nonnull String languageId) {
  Language language = Language.findLanguageByID(languageId);
  return language == null ? ContainerUtil.<Annotator>emptyList() : LanguageAnnotators.INSTANCE.allForLanguage(language);
}
项目:consulo    文件:CachedAnnotators.java   
@Nonnull
List<Annotator> get(@Nonnull String languageId) {
  return cachedAnnotators.get(languageId);
}