@Test public void after_Remove() throws IOException { final Project project = testHelper.getFixture().getProject(); final GeneratedFilesListener listener = new GeneratedFilesListener(project); final PsiFile file = testHelper.configure("LayoutSpec.java"); ApplicationManager.getApplication() .invokeAndWait( () -> { final PsiClass cls = PsiTreeUtil.findChildOfType(file, PsiClass.class); ComponentGenerateService.getInstance().updateLayoutComponentAsync(cls); final ComponentsCacheService service = ComponentsCacheService.getInstance(project); final PsiClass component = service.getComponent("Layout"); assertThat(component).isNotNull(); final VFileEvent mockEvent = mockEvent(); PsiSearchUtils.addMock("Layout", cls); listener.after(Collections.singletonList(mockEvent)); final PsiClass component2 = service.getComponent("Layout"); assertThat(component2).isNull(); }); }
@Override public void after(List<? extends VFileEvent> events) { IntervalLogger logger = new IntervalLogger(LOG); final boolean found = events.stream() .filter(VFileCreateEvent.class::isInstance) .map(VFileEvent::getFile) .filter(file -> file != null && file.isValid()) .map(file -> FileUtil.toSystemIndependentName(file.getPath())) .anyMatch(GeneratedFilesListener::isOutput); logger.logStep("finding created paths: " + found); if (!found) return; final Runnable job = () -> { logger.logStep("start of removing files"); ComponentsCacheService.getInstance(project).invalidate(); }; if (ApplicationManager.getApplication().isUnitTestMode()) { job.run(); } else { DumbService.getInstance(project).smartInvokeLater(job); } }
GeneratedFilesListener implements BulkFileListener, Disposable { @Override public void after(List<? extends VFileEvent> events) { IntervalLogger logger = new IntervalLogger(LOG); final boolean found = events.stream() .filter(VFileCreateEvent.class::isInstance) .map(VFileEvent::getFile) .filter(file -> file != null && file.isValid()) .map(file -> FileUtil.toSystemIndependentName(file.getPath())) .anyMatch(GeneratedFilesListener::isOutput); logger.logStep("finding created paths: " + found); if (!found) return; final Runnable job = () -> { logger.logStep("start of removing files"); ComponentsCacheService.getInstance(project).invalidate(); }; if (ApplicationManager.getApplication().isUnitTestMode()) { job.run(); } else { DumbService.getInstance(project).smartInvokeLater(job); } } }
GeneratedFilesListener implements BulkFileListener, Disposable { @Override public void after(List<? extends VFileEvent> events) { IntervalLogger logger = new IntervalLogger(LOG); final boolean found = events.stream() .filter(VFileCreateEvent.class::isInstance) .map(VFileEvent::getFile) .filter(file -> file != null && file.isValid()) .map(file -> FileUtil.toSystemIndependentName(file.getPath())) .anyMatch(GeneratedFilesListener::isOutput); logger.logStep("finding created paths: " + found); if (!found) return; final Runnable job = () -> { logger.logStep("start of removing files"); ComponentsCacheService.getInstance(project).invalidate(); }; if (ApplicationManager.getApplication().isUnitTestMode()) { job.run(); } else { DumbService.getInstance(project).smartInvokeLater(job); } } GeneratedFilesListener(Project project); }
GeneratedFilesListener implements BulkFileListener, Disposable { @Override public void after(List<? extends VFileEvent> events) { IntervalLogger logger = new IntervalLogger(LOG); final boolean found = events.stream() .filter(VFileCreateEvent.class::isInstance) .map(VFileEvent::getFile) .filter(file -> file != null && file.isValid()) .map(file -> FileUtil.toSystemIndependentName(file.getPath())) .anyMatch(GeneratedFilesListener::isOutput); logger.logStep("finding created paths: " + found); if (!found) return; final Runnable job = () -> { logger.logStep("start of removing files"); ComponentsCacheService.getInstance(project).invalidate(); }; if (ApplicationManager.getApplication().isUnitTestMode()) { job.run(); } else { DumbService.getInstance(project).smartInvokeLater(job); } } GeneratedFilesListener(Project project); @Override void dispose(); @Override void after(List<? extends VFileEvent> events); }
GeneratedFilesListener implements BulkFileListener, Disposable { @Override public void after(List<? extends VFileEvent> events) { IntervalLogger logger = new IntervalLogger(LOG); final boolean found = events.stream() .filter(VFileCreateEvent.class::isInstance) .map(VFileEvent::getFile) .filter(file -> file != null && file.isValid()) .map(file -> FileUtil.toSystemIndependentName(file.getPath())) .anyMatch(GeneratedFilesListener::isOutput); logger.logStep("finding created paths: " + found); if (!found) return; final Runnable job = () -> { logger.logStep("start of removing files"); ComponentsCacheService.getInstance(project).invalidate(); }; if (ApplicationManager.getApplication().isUnitTestMode()) { job.run(); } else { DumbService.getInstance(project).smartInvokeLater(job); } } GeneratedFilesListener(Project project); @Override void dispose(); @Override void after(List<? extends VFileEvent> events);  }