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 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); } }
private void registerAnnotatorWithAllLanguages() { for( Language lang: Language.getRegisteredLanguages() ) { LanguageAnnotators.INSTANCE.addExplicitExtension( lang, new ManifoldPsiClassAnnotator() ); } }
@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); } }
@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 }
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); } }
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()); }
@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; }
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); }
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; }
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); } }
@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 }
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); }
@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); }