GroovyCodeFragment () { final GroovyCodeFragment clone = (GroovyCodeFragment)cloneImpl((FileElement)calcTreeElement().clone()); clone.myOriginalFile = this; clone.myImportCollector.setFrom(myImportCollector); FileManager fileManager = ((PsiManagerEx)getManager()).getFileManager(); SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider)fileManager.createFileViewProvider(new LightVirtualFile( getName(), getLanguage(), getText()), false); cloneViewProvider.forceCachedPsi(clone); clone.myViewProvider = cloneViewProvider; return clone; }