@Test public void daemonFinished_settingsFalse_notResolved() throws IOException { final PsiFile specPsiFile = testHelper.configure("LayoutSpec.java"); final PsiFile fileUnderTest = testHelper.configure("ResolveRedSymbolsActionTest.java"); final Project project = testHelper.getFixture().getProject(); AppSettingsState.getInstance(project).getState().resolveRedSymbols = false; ApplicationManager.getApplication() .invokeAndWait( () -> { PsiSearchUtils.addMock( "LayoutSpec", PsiTreeUtil.findChildOfType(specPsiFile, PsiClass.class)); ResolveRedSymbolsActionTest.parseDocument( testHelper.getFixture().getEditor().getDocument(), fileUnderTest, project); new OnCodeAnalysisFinishedListener(project).daemonFinished(); }); final PsiClass cached = ComponentsCacheService.getInstance(project).getComponent("Layout"); assertThat(cached).isNull(); }
@Override public void daemonFinished() { LOG.debug("Daemon finished"); final AppSettingsState.Model state = AppSettingsState.getInstance(project).getState(); if (!state.resolveRedSymbols) return; Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; final Document document = editor.getDocument(); final VirtualFile vf = FileDocumentManager.getInstance().getFile(document); if (vf == null) return; final String path = vf.getPath(); boolean stopProcessing = analyzedFiles.contains(path) || pendingFiles.contains(path); if (stopProcessing) return; final PsiFile pf = PsiManager.getInstance(project).findFile(vf); if (!(pf instanceof PsiJavaFile)) return; if (DumbService.isDumb(project)) return; pendingFiles.add(path); final Map<String, String> eventMetadata = new HashMap<>(); ResolveRedSymbolsAction.resolveRedSymbols( (PsiJavaFile) pf, vf, editor, project, eventMetadata, newSymbolsFound -> { pendingFiles.remove(path); analyzedFiles.add(path); eventMetadata.put(EventLogger.KEY_TYPE, "daemon"); eventMetadata.put(EventLogger.KEY_RESULT, newSymbolsFound ? "success" : "fail"); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_RED_SYMBOLS, eventMetadata); }); }
OnCodeAnalysisFinishedListener implements DaemonCodeAnalyzer.DaemonListener, FileEditorManagerListener, Disposable { @Override public void daemonFinished() { LOG.debug("Daemon finished"); final AppSettingsState.Model state = AppSettingsState.getInstance(project).getState(); if (!state.resolveRedSymbols) return; Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; final Document document = editor.getDocument(); final VirtualFile vf = FileDocumentManager.getInstance().getFile(document); if (vf == null) return; final String path = vf.getPath(); boolean stopProcessing = analyzedFiles.contains(path) || pendingFiles.contains(path); if (stopProcessing) return; final PsiFile pf = PsiManager.getInstance(project).findFile(vf); if (!(pf instanceof PsiJavaFile)) return; if (DumbService.isDumb(project)) return; pendingFiles.add(path); final Map<String, String> eventMetadata = new HashMap<>(); ResolveRedSymbolsAction.resolveRedSymbols( (PsiJavaFile) pf, vf, editor, project, eventMetadata, newSymbolsFound -> { pendingFiles.remove(path); analyzedFiles.add(path); eventMetadata.put(EventLogger.KEY_TYPE, "daemon"); eventMetadata.put(EventLogger.KEY_RESULT, newSymbolsFound ? "success" : "fail"); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_RED_SYMBOLS, eventMetadata); }); } }
OnCodeAnalysisFinishedListener implements DaemonCodeAnalyzer.DaemonListener, FileEditorManagerListener, Disposable { @Override public void daemonFinished() { LOG.debug("Daemon finished"); final AppSettingsState.Model state = AppSettingsState.getInstance(project).getState(); if (!state.resolveRedSymbols) return; Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; final Document document = editor.getDocument(); final VirtualFile vf = FileDocumentManager.getInstance().getFile(document); if (vf == null) return; final String path = vf.getPath(); boolean stopProcessing = analyzedFiles.contains(path) || pendingFiles.contains(path); if (stopProcessing) return; final PsiFile pf = PsiManager.getInstance(project).findFile(vf); if (!(pf instanceof PsiJavaFile)) return; if (DumbService.isDumb(project)) return; pendingFiles.add(path); final Map<String, String> eventMetadata = new HashMap<>(); ResolveRedSymbolsAction.resolveRedSymbols( (PsiJavaFile) pf, vf, editor, project, eventMetadata, newSymbolsFound -> { pendingFiles.remove(path); analyzedFiles.add(path); eventMetadata.put(EventLogger.KEY_TYPE, "daemon"); eventMetadata.put(EventLogger.KEY_RESULT, newSymbolsFound ? "success" : "fail"); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_RED_SYMBOLS, eventMetadata); }); } OnCodeAnalysisFinishedListener(Project project); }
OnCodeAnalysisFinishedListener implements DaemonCodeAnalyzer.DaemonListener, FileEditorManagerListener, Disposable { @Override public void daemonFinished() { LOG.debug("Daemon finished"); final AppSettingsState.Model state = AppSettingsState.getInstance(project).getState(); if (!state.resolveRedSymbols) return; Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; final Document document = editor.getDocument(); final VirtualFile vf = FileDocumentManager.getInstance().getFile(document); if (vf == null) return; final String path = vf.getPath(); boolean stopProcessing = analyzedFiles.contains(path) || pendingFiles.contains(path); if (stopProcessing) return; final PsiFile pf = PsiManager.getInstance(project).findFile(vf); if (!(pf instanceof PsiJavaFile)) return; if (DumbService.isDumb(project)) return; pendingFiles.add(path); final Map<String, String> eventMetadata = new HashMap<>(); ResolveRedSymbolsAction.resolveRedSymbols( (PsiJavaFile) pf, vf, editor, project, eventMetadata, newSymbolsFound -> { pendingFiles.remove(path); analyzedFiles.add(path); eventMetadata.put(EventLogger.KEY_TYPE, "daemon"); eventMetadata.put(EventLogger.KEY_RESULT, newSymbolsFound ? "success" : "fail"); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_RED_SYMBOLS, eventMetadata); }); } OnCodeAnalysisFinishedListener(Project project); @Override void dispose(); @Override void daemonFinished(); @Override void daemonCancelEventOccurred(String reason); @Override void selectionChanged(FileEditorManagerEvent event); }
OnCodeAnalysisFinishedListener implements DaemonCodeAnalyzer.DaemonListener, FileEditorManagerListener, Disposable { @Override public void daemonFinished() { LOG.debug("Daemon finished"); final AppSettingsState.Model state = AppSettingsState.getInstance(project).getState(); if (!state.resolveRedSymbols) return; Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) return; final Document document = editor.getDocument(); final VirtualFile vf = FileDocumentManager.getInstance().getFile(document); if (vf == null) return; final String path = vf.getPath(); boolean stopProcessing = analyzedFiles.contains(path) || pendingFiles.contains(path); if (stopProcessing) return; final PsiFile pf = PsiManager.getInstance(project).findFile(vf); if (!(pf instanceof PsiJavaFile)) return; if (DumbService.isDumb(project)) return; pendingFiles.add(path); final Map<String, String> eventMetadata = new HashMap<>(); ResolveRedSymbolsAction.resolveRedSymbols( (PsiJavaFile) pf, vf, editor, project, eventMetadata, newSymbolsFound -> { pendingFiles.remove(path); analyzedFiles.add(path); eventMetadata.put(EventLogger.KEY_TYPE, "daemon"); eventMetadata.put(EventLogger.KEY_RESULT, newSymbolsFound ? "success" : "fail"); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_RED_SYMBOLS, eventMetadata); }); } OnCodeAnalysisFinishedListener(Project project); @Override void dispose(); @Override void daemonFinished(); @Override void daemonCancelEventOccurred(String reason); @Override void selectionChanged(FileEditorManagerEvent event);  }