codeintel: allow optional callback argument for scan document

(integrated from master branch change 82aadb1 by Todd Whiteman <toddw@activestate.com>)