PsiFile (@NotNull PsiFile file, Class @NotNull [] classes) { final Project project = file.getProject(); SoftFactoryMap<Class[], PsiFile> map = project.getUserData(PATTERN_INJECTION_CONTEXT); if (map == null) { map = new SoftFactoryMap<>() { @Override protected PsiFile create(Class @NotNull [] key) { String text = PatternCompilerFactory.getFactory().getPatternCompiler(key).dumpContextDeclarations(); return PsiFileFactory.getInstance(project).createFileFromText("context.groovy", GroovyFileType.GROOVY_FILE_TYPE, text); } }; project.putUserData(PATTERN_INJECTION_CONTEXT, map); } return map.get(classes); }