Java 类com.intellij.lang.LanguageAnnotators 实例源码

项目: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());
}
项目:intellij-haxe    文件:HaxeAnnotationTest.java   
private void doTest(String... additionalPaths) throws Exception {
  final String[] paths = ArrayUtil.append(additionalPaths, getTestName(false) + ".hx");
  myFixture.configureByFiles(ArrayUtil.reverseArray(paths));
  final HaxeTypeAnnotator annotator = new HaxeTypeAnnotator();
  try {
    LanguageAnnotators.INSTANCE.addExplicitExtension(HaxeLanguage.INSTANCE, annotator);
    myFixture.enableInspections(getAnnotatorBasedInspection());
    try {
      myFixture.testHighlighting(true, true, true, myFixture.getFile().getVirtualFile());
    }
    finally {
      LanguageAnnotators.INSTANCE.removeExplicitExtension(HaxeLanguage.INSTANCE, annotator);
    }
  } finally {
    LanguageAnnotators.INSTANCE.removeExplicitExtension(HaxeLanguage.INSTANCE, annotator);
  }
}
项目:manifold-ij    文件:ManApplicationComponent.java   
private void registerAnnotatorWithAllLanguages()
{
  for( Language lang: Language.getRegisteredLanguages() )
  {
    LanguageAnnotators.INSTANCE.addExplicitExtension( lang, new ManifoldPsiClassAnnotator() );
  }
}
项目:intellij-ce-playground    文件:DaemonAnalyzerTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  final LocalInspectionTool[] tools = configureLocalInspectionTools();

  CodeInsightTestFixtureImpl.configureInspections(tools, getProject(), Collections.<String>emptyList(),
                                                  getTestRootDisposable());

  DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
  daemonCodeAnalyzer.prepareForTest();
  final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject());
  startupManager.runStartupActivities();
  startupManager.startCacheUpdate();
  startupManager.runPostStartupActivities();
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);

  if (isPerformanceTest()) {
    IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
    PathManagerEx.getTestDataPath(); // to cache stuff
    ReferenceProvidersRegistry.getInstance(); // pre-load tons of classes
    InjectedLanguageManager.getInstance(getProject()); // zillion of Dom Sem classes
    LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE); // pile of annotator classes loads
    LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML);
    ProblemHighlightFilter.EP_NAME.getExtensions();
    Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
    Extensions.getExtensions(XmlSchemaProvider.EP_NAME);
    Extensions.getExtensions(XmlFileNSInfoProvider.EP_NAME);
    Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
    Extensions.getExtensions(IndexPatternBuilder.EP_NAME);
  }
}
项目:intellij-ce-playground    文件:LightAdvHighlightingPerformanceTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LanguageAnnotators.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(JavaConcatenationInjectorManager.CONCATENATION_INJECTOR_EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME)));

  IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
  PathManagerEx.getTestDataPath(); // to cache stuff
}
项目: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);
  }
}
项目:intellij-ce-playground    文件:PropertiesCoreEnvironment.java   
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(PropertiesFileType.INSTANCE, "properties");
  appEnvironment.addExplicitExtension(SyntaxHighlighterFactory.LANGUAGE_FACTORY, PropertiesLanguage.INSTANCE,
                                      new PropertiesSyntaxHighlighterFactory());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesParserDefinition());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlPropertiesIndex());
  appEnvironment.addExtension(StubIndexExtension.EP_NAME, new PropertyKeyIndex());

  appEnvironment.registerApplicationService(PropertiesQuickFixFactory.class, new EmptyPropertiesQuickFixFactory());
  appEnvironment.registerApplicationService(PropertiesRefactoringSettings.class, new PropertiesRefactoringSettings());
  appEnvironment.addExplicitExtension(LanguageAnnotators.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesAnnotator());
  appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesFindUsagesProvider());

  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesASTFactory());
  appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesFoldingBuilder());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyImpl.class, new PropertyManipulator());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyKeyImpl.class, new PropertyKeyManipulator());
  appEnvironment.addExplicitExtension(ElementManipulators.INSTANCE, PropertyValueImpl.class, new PropertyValueManipulator());

  final StubElementTypeHolderEP stubElementTypeHolderBean = new StubElementTypeHolderEP();
  stubElementTypeHolderBean.holderClass = PropertiesElementTypes.class.getName();
  appEnvironment.addExtension(StubElementTypeHolderEP.EP_NAME, stubElementTypeHolderBean);

  appEnvironment.addExplicitExtension(LanguageCommenters.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesCommenter());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, PropertiesFileType.INSTANCE, new PropertiesIdIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, PropertiesFileType.INSTANCE, new PropertiesTodoIndexer());

  appEnvironment.addExtension(IconProvider.EXTENSION_POINT_NAME, new XmlPropertiesIconProvider());
}
项目: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    文件:LightAdvHighlightingPerformanceTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LanguageAnnotators.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(JavaConcatenationInjectorManager.CONCATENATION_INJECTOR_EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME)));

  IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
  PathManagerEx.getTestDataPath(); // to cache stuff
}
项目: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);
  }
}
项目:intellij-haxe    文件:HaxeSemanticAnnotatorTest.java   
private void doTestNoFix(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, String... additionalFiles) throws Exception {
  myFixture.configureByFiles(ArrayUtil.mergeArrays(new String[]{getTestName(false) + ".hx"}, additionalFiles));
  final HaxeTypeAnnotator annotator = new HaxeTypeAnnotator();
  LanguageAnnotators.INSTANCE.addExplicitExtension(HaxeLanguage.INSTANCE, annotator);
  myFixture.enableInspections(getAnnotatorBasedInspection());
  myFixture.testHighlighting(true, false, true);
}
项目:intellij-haxe    文件:HaxeSemanticBodyAnnotatorTest.java   
private void doTestNoFix(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings) throws Exception {
  boolean old = HaxeSemanticAnnotatorConfig.ENABLE_EXPERIMENTAL_BODY_CHECK;
  HaxeSemanticAnnotatorConfig.ENABLE_EXPERIMENTAL_BODY_CHECK = true;
  myFixture.configureByFiles(getTestName(false) + ".hx");
  final HaxeTypeAnnotator annotator = new HaxeTypeAnnotator();
  LanguageAnnotators.INSTANCE.addExplicitExtension(HaxeLanguage.INSTANCE, annotator);
  myFixture.enableInspections(getAnnotatorBasedInspection());
  myFixture.testHighlighting(true, false, false);
  HaxeSemanticAnnotatorConfig.ENABLE_EXPERIMENTAL_BODY_CHECK = old;
}
项目: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-haxe    文件:HaxeAnnotationTest.java   
private void doTest(String... additionalPaths) throws Exception {
  final String[] paths = ArrayUtil.append(additionalPaths, getTestName(false) + ".hx");
  myFixture.configureByFiles(ArrayUtil.reverseArray(paths));
  final HaxeTypeAnnotator annotator = new HaxeTypeAnnotator();
  LanguageAnnotators.INSTANCE.addExplicitExtension(HaxeLanguage.INSTANCE, annotator);
  myFixture.enableInspections(new DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection());
  try {
    myFixture.testHighlighting(true, true, true, myFixture.getFile().getVirtualFile());
  }
  finally {
    LanguageAnnotators.INSTANCE.removeExplicitExtension(HaxeLanguage.INSTANCE, annotator);
  }
}
项目:consulo-java    文件:LightAdvHighlightingPerformanceTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LanguageAnnotators.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getRootArea().getExtensionPoint(LineMarkerProviders.EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(JavaConcatenationInjectorManager.CONCATENATION_INJECTOR_EP_NAME)));
  Disposer.register(my, BlockExtensions.create(Extensions.getArea(getProject()).getExtensionPoint(MultiHostInjector.EP_NAME)));

  IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
}
项目: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);
}
项目:tools-idea    文件:DefaultHighlightVisitor.java   
@NotNull
@Override
public Collection<Annotator> initialValue(@NotNull Language key) {
  return LanguageAnnotators.INSTANCE.allForLanguage(key);
}
项目: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);
}