PsiJavaFile (Project project) { final String source = """ package abc; public interface MyInterface { static void staticMethod() {} default void instanceMethod() {} } """; final FileType fileType = JavaFileType.INSTANCE; return (PsiJavaFile)PsiFileFactory.getInstance(project).createFileFromText( ABC_MY_INTERFACE + '.' + fileType.getDefaultExtension(), fileType, source); }