use of com.intellij.openapi.vfs.encoding.EncodingManagerImpl in project intellij-community by JetBrains.
the class UsageViewTest method testUsageViewDoesNotHoldPsiFilesOrDocuments.
public void testUsageViewDoesNotHoldPsiFilesOrDocuments() throws Exception {
boolean[] foundLeaksBeforeTest = new boolean[1];
LeakHunter.checkLeak(ApplicationManager.getApplication(), PsiFileImpl.class, file -> {
if (!file.isPhysical())
return false;
System.err.println("Can't start the test: leaking PsiFiles found:");
foundLeaksBeforeTest[0] = true;
return true;
});
if (foundLeaksBeforeTest[0]) {
fail("Can't start the test: leaking PsiFiles found");
}
PsiFile psiFile = myFixture.addFileToProject("X.java", "public class X{} //iuggjhfg");
Usage[] usages = new Usage[100];
for (int i = 0; i < usages.length; i++) {
usages[i] = createUsage(psiFile, i);
}
UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, usages, new UsageViewPresentation(), null);
Disposer.register(myFixture.getTestRootDisposable(), usageView);
((EncodingManagerImpl) EncodingManager.getInstance()).clearDocumentQueue();
FileDocumentManager.getInstance().saveAllDocuments();
UIUtil.dispatchAllInvocationEvents();
LeakHunter.checkLeak(usageView, PsiFileImpl.class, PsiFileImpl::isPhysical);
LeakHunter.checkLeak(usageView, Document.class);
}
Aggregations