@Nullable
    public static ResourceInfo findRecentScript(RCPProject project, @Nullable SQLNavigatorContext context) throws CoreException
    {
        List<ResourceInfo> scripts = new ArrayList<>();
        findScriptList(
            project,
            getScriptsFolder(project, false),
            context == null ? null : context.getDataSourceContainer(),
            scripts);

        long recentTimestamp = 0L;
        ResourceInfo recentFile = null;
        for (ResourceInfo file : scripts) {
            if (file.resource != null) {
                long lastModified = ResourceUtils.getResourceLastModified(file.resource);
                if (lastModified > recentTimestamp) {
                    recentTimestamp = lastModified;
                    recentFile = file;
                }
            }
        }
        return recentFile;
    }
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