Example #1
0
def resolve_symbols_in_file(filepath):
    io.write_next_action('Resolve symbols in %s' % os.path.basename(filepath))

    tree = parse_file(filepath)

    trans = transformer.Transformer()
    symbols = trans.resolve_symbols_in_unit(tree)

    return symbols
Example #2
0
def find_forms(graph):
    # first try to do a wide sweep finding all forms in codebase
    # this is to find forms that are pulled in from dcus which cannot be
    # traced
    projfile = os.path.join(graph.abspath, graph.rootnode.path, graph.rootnode.filename)
    if projroot:
        io.write_next_action("Finding all forms in %s" % projroot)
        forms = io.ifind(projroot, "*.dfm")
        io.write_result("Found [%s]" % ", ".join(forms))
        if forms:
            return forms

    # otherwise just return all the forms in the graph
    forms = graph.rootnode.collect_nodes(lambda n: n.filetype == FileTypes.Form)
    forms = map(lambda n: os.path.join(graph.abspath, n.path, n.filename), forms)
    return forms
Example #3
0
        def trace_deps(filepath, searchpath, stdlibpath, unitaliases,
                       depth=0, maxdepth=None):
            # don't prevent calls on filepaths already in index so as to resolve
            # cycles properly, but catch these here to return a valid object
            # for a filepath already known
            if self.index_has(filepath):
                return self.index_get(filepath)

            io.write_next_action("Tracing %s" % os.path.basename(filepath),
                                                                 indent=depth)

            filepath, exists, filetype = classify_file(filepath, searchpath,
                                                       stdlibpath)
            delphifile = self.new_delphifile(filepath,
                                             (filepath, exists, filetype))
            if exists:
                searchpath = collect_searchpath(searchpath, delphifile,
                                                filepath)
                unitaliases = collect_unitaliases(unitaliases, delphifile,
                                                  filepath)
                finder_function = finder_dispatch.get(filetype)
                if finder_function:
                    fps = finder_function(open(filepath).read(),
                                          parent=delphifile)
                    io.write_result('Found [%s]' % ', '.join(fps), indent=depth)
                    fps = process_filepaths(delphifile.path, unitaliases, fps)
                    if not maxdepth or maxdepth >= depth+1:
                        for fp in fps:
                            delphifile.add_node(trace_deps(fp,
                                                           searchpath,
                                                           stdlibpath,
                                                           unitaliases,
                                                           depth=depth+1,
                                                           maxdepth=maxdepth))

            return delphifile