'Scan the given multilang (UDL-based) buffer and return a CIX
element tree.
"buf" is the multi-lang Buffer instance (e.g.
lang_rhtml.RHTMLBuffer for RHTML).
"csl_cile_driver" (optional) is the CSL (client-side language)
CILE driver. While scanning, CSL tokens should be gathered and,
if any, passed to the CSL scanner like this:
csl_cile_driver.scan_csl_tokens(
file_elem, blob_name, csl_tokens)
The CSL scanner will append a CIX <scope ilk="blob">
element to the <file> element.'

def scan_multilang(self, buf, csl_cile_driver=None):

    log.info('scan_multilang:    path:    %r    lang:    %s', buf.path, buf.lang)
    tree = Element('codeintel', version='2.0')
    path = buf.path
    if (sys.platform == 'win32'):
        path = path.replace('\\', '/')
    file = SubElement(tree, 'file', lang=buf.lang, path=path)
    module = SubElement(file, 'scope', ilk='blob', lang='Ruby', name=basename(buf.path))
    (csl_tokens, has_ruby_code) = rubycile.scan_multilang(buf.accessor.gen_tokens(), module)
    rubycile.check_insert_rails_env(path, module)
    if (not has_ruby_code):
        assert (len(module) == 0)
        file.remove(module)
    if (csl_cile_driver and csl_tokens):
        csl_cile_driver.scan_csl_tokens(file, basename(buf.path), csl_tokens)
    return tree
