public void invoke( @NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { PsiDocumentManager.getInstance(project).commitAllDocuments(); final LookupEx lookup = LookupManagerImpl.getActiveLookup(editor); if (lookup != null) { lookup.showElementActions(); return; } if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction()) return; // intentions check isWritable before modification: if (!file.isWritable()) return; if (file instanceof PsiCodeFragment) return; TemplateState state = TemplateManagerImpl.getTemplateState(editor); if (state != null && !state.isFinished()) { return; } final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project); codeAnalyzer.autoImportReferenceAtCursor(editor, file); // let autoimport complete ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo(); ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1); if (!intentions.isEmpty()) { IntentionHintComponent.showIntentionHint(project, file, editor, intentions, true); } }
@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); } }
@NotNull protected Collection<HighlightInfo> checkHighlighting( @NotNull final ExpectedHighlightingData data) { data.init(); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); // to load text ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { TreeUtil.clearCaches((TreeElement) myFile.getNode()); } }); // to initialize caches if (!DumbService.isDumb(getProject())) { CacheManager.SERVICE .getInstance(myProject) .getFilesWithWord( "XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true); } final JavaPsiFacadeEx facade = getJavaFacade(); if (facade != null) { facade.setAssertOnFileLoadingFilter( myFileTreeAccessFilter, myTestRootDisposable); // check repository work } try { Collection<HighlightInfo> infos = doHighlighting(); String text = myEditor.getDocument().getText(); data.checkLineMarkers( DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text); data.checkResult(infos, text); return infos; } finally { if (facade != null) { facade.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable); } } }
private List<LineMarkerInfo> getInfos(String fileName) { myFixture.configureByFile(getTestDataPath() + "/codeInsight/runLineMarker/" + fileName); myFixture.doHighlighting(); return DaemonCodeAnalyzerImpl.getLineMarkers( myFixture.getEditor().getDocument(), myFixture.getProject()); }