@NotNull
    private static List<ResourceInfo> getScriptsFromFolder(@NotNull IFolder folder) throws CoreException {
        List<ResourceInfo> scripts = new ArrayList<>();
        for (IResource member : folder.members()) {
            if (member instanceof IFile iFile) {
                ResourceInfo resourceInfo = new ResourceInfo(iFile, EditorUtils.getFileDataSource(iFile));
                scripts.add(resourceInfo);
            }
            if (member instanceof IFolder iFolder){
                scripts.addAll(getScriptsFromFolder(iFolder));
            }
        }
        return scripts;
    }
A {@link IResource}'s session property to distinguish between persisted and newly created resources.
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditorUtils.java