Exemplo n.º 1
0
def prepare_path(graph, use_abspath=None):
    searchpath = graph.searchpath

    # find all stdlib paths not in searchpath
    nodes = graph.rootnode.collect_nodes(lambda n: n != None)
    stdlibpath = util.iuniq(map(lambda n: n.path, nodes))
    stdlibpath = util.setminus(stdlibpath, searchpath)

    # filter stdlibpath with respect to searchpath
    if io.platform_is_cygwin():
        for path in stdlibpath:
            if io.path_cygwin_to_win(path) in searchpath:
                stdlibpath.remove(path)

    # filter for empties
    searchpath = filter(lambda p: p != "", searchpath)
    stdlibpath = filter(lambda p: p != "", stdlibpath)

    # make relative to given abspath
    if use_abspath:

        def rebase_path(path):
            oldcwd = os.getcwd()
            try:
                os.chdir(graph.abspath)
                path = os.path.abspath(path)
            finally:
                os.chdir(oldcwd)
            path = io.relpath(path, relative_to=use_abspath)
            return path

        searchpath = map(rebase_path, searchpath)
        stdlibpath = map(rebase_path, stdlibpath)

    # if cygwin make stdlibpath absolute
    if io.platform_is_cygwin():
        abs = lambda p: io.path_join(graph.abspath, p)
        stdlibpath = map(abs, stdlibpath)

    # group
    include = searchpath + stdlibpath

    # if cygwin convert to winpaths
    if io.platform_is_cygwin():
        include = map(lambda p: io.path_cygwin_to_win(p), include)

    # kill dupes
    include = util.iuniq(include)

    # join
    include_s = ";".join(include)

    return include_s
Exemplo n.º 2
0
    def find_symbols_in_func(self, node):
        assert(type(node) == ProcedureImplDecl)

        params = []
        ts = self.find_params_in_func(node)
        for t in ts:
            params.append(self.mksym_param(t))

        consts = []
        ts = self.find_consts_in_func(node)
        for t in ts:
            consts.append(self.mksym_const(t))

        types = []
        ts = self.find_types_in_func(node)
        for t in ts:
            types.append(self.mksym_type(t))

        vars = []
        ts = self.find_vars_in_func(node)
        for t in ts:
            vars.append(self.mksym_var(t))

        symbols = self.find(node, [Many, ProcedureBodySemi, Many, QualifiedId])
        symbols = map(self.find_str, symbols)
        symbols = util.iuniq(symbols)
        symbols = map(self.mksym_symbol, symbols)

        return symbols, (params, consts, types, vars)
Exemplo n.º 3
0
 def __init__(self, rootnode, abspath, searchpath, stdlibpath):
     self.rootnode = rootnode
     self.abspath = abspath
     # XXX for some inexplicable reason the searchpath is duplicated
     # when tracing with explore_codebase
     self.searchpath = util.iuniq(searchpath)
     self.stdlibpath = stdlibpath
     self.index = None
Exemplo n.º 4
0
    def resolve_symbols_in_scope(self, node, implsyms, unitsyms):
        symbols = self.find(node, [Many, StatementList, Many, QualifiedId])
        symbols = map(self.find_str, symbols)
        symbols = util.iuniq(symbols)

        args = [symbols, None, None] \
                + [[],[],[],[],] + list(implsyms) + list(unitsyms)
        index = Scope.resolve(*args)

        return index
Exemplo n.º 5
0
def collect_searchpath(searchpath, delphifile, filepath):
    if delphifile.filetype == FileTypes.DelphiProject:
        sp = finders.find_SearchPath(open(filepath).read(), filepath=filepath)
        curpath = delphifile.path
        for p in sp:
            if io.platform_is_posix() and io.path_is_win(p):
                p = io.path_win_to_posix(p)
            p = os.path.join(curpath, p)
            p = os.path.normpath(p)
            searchpath.append(p)
        searchpath = util.iuniq(searchpath)
    return searchpath