PsiFile (final Language language, CharSequence sourceCode, PsiManager manager) { final @NonNls LightVirtualFile virtualFile = new LightVirtualFile("foo", createTemplateFakeFileType(language), sourceCode, LocalTimeCounter.currentTime()); FileViewProvider viewProvider = new SingleRootFileViewProvider(manager, virtualFile, false) { @Override public @NotNull Language getBaseLanguage() { return language; } }; // Since we're already inside a template language PSI that was built regardless of the file size (for whatever reason), // there should also be no file size checks for template data files. SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile); return viewProvider.getPsi(language); }