PsiFile (@NotNull AbstractBasicJavaParsingTestCase thinJavaParsingTestCase, @NotNull String name, @NotNull String text, @NotNull Consumer<PsiBuilder> parser) { if (TEST_FILE_ELEMENT_TYPE == null) { TEST_FILE_ELEMENT_TYPE = new MyIFileElementType(); } TEST_PARSER = parser; LightVirtualFile virtualFile = new LightVirtualFile(name + '.' + "java", JavaFileType.INSTANCE, text, -1); FileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(thinJavaParsingTestCase.getProject()), virtualFile, true); PsiJavaFileImpl file = new PsiJavaFileImpl(viewProvider) { @NotNull @Override protected FileElement createFileElement(@NotNull CharSequence text) { return new FileElement(TEST_FILE_ELEMENT_TYPE, text); } }; configure(file); return file; }