void () { IntRef invocations = new IntRef(0); VirtualFileGist<String> gistProjectName = GistManager.getInstance().newVirtualFileGist(getTestName(true), 0, EnumeratorStringDescriptor.INSTANCE, (p, f) -> { invocations.inc(); return (p == null ? null : p.getName()); }); VirtualFile file = fileWithContent("a.txt", "foo bar"); final Project project1 = getProject(); final Project project2 = ProjectManager.getInstance().getDefaultProject(); String project1Name = project1.getName(); String project2Name = project2.getName(); assertEquals( "Gist calculated 1st time for project1", project1Name, gistProjectName.getFileData(project1, file) ); assertEquals(1, invocations.get()); assertEquals( "Gist DOES recalculated for project2", project2Name, gistProjectName.getFileData(project2, file) ); assertEquals(2, invocations.get()); assertEquals( "Gist does NOT recalculated for project1", project1Name, gistProjectName.getFileData(project1, file) ); assertEquals(2, invocations.get()); assertNull( "Gist DOES recalculated for null project", gistProjectName.getFileData(null, file) ); assertEquals(3, invocations.get()); }