Exemplo n.º 1
0
    def completions(self):
        """
        Return :class:`classes.Completion` objects. Those objects contain
        information about the completions, more than just names.

        :return: Completion objects, sorted by name.
        :rtype: list of :class:`classes.Completion`
        """
        debug.speed('completions start')
        comps = self._evaluator.complete()
        debug.speed('completions end')

        return sorted(comps, key=lambda x: (x.name.lower()))
Exemplo n.º 2
0
    def completions(self):
        """
        Return :class:`classes.Completion` objects. Those objects contain
        information about the completions, more than just names.

        :return: Completion objects, sorted by name.
        :rtype: list of :class:`classes.Completion`
        """
        debug.speed('completions start')
        comps = self._evaluator.complete()
        debug.speed('completions end')

        return sorted(comps, key=lambda x: (x.name.lower()))
Exemplo n.º 3
0
    def __init__(self, source=None, line=None, column=None, path=None):
        self._orig_path = path
        self.path = None if path is None else os.path.abspath(path)

        #Here we need to add support for tramp over SSH for the file that
        #is being edited. We will have cached versions of the other modules
        #in the global code cache, but we need to update the file being
        #edited in that cache so that any other buffers with reference to
        #this module being edited have the latest information.
        if source is None:
            source = cache.parser().tramp.read(path)

        #This section makes sure that the argument we have from the buffer
        #for the line number actually makes sense for the source code we have.
        lines = source.splitlines() or ['']
        if source and source[-1] == '\n':
            lines.append('')
        line = max(len(lines), 1) if line is None else line
        if not (0 < line <= len(lines)):
            raise ValueError('`line` parameter is not in a valid range.')

        #Same thing as above, except we are checking validity of column.
        line_len = len(lines[line - 1])
        column = line_len if column is None else column
        if not (0 <= column <= line_len):
            raise ValueError('`column` parameter is not in a valid range.')
        self._pos = line - 1, column

        #Clear the time dependent caches. These are things we cached related
        #to completion but *not* to parsing. This is because multiple calls
        #can be made for completion of a symbol while on the same line of code.
        cache.clear_caches()
        #This is the timing module for the parsing etc. to find bottlenecks
        #and help optimize the code. It sets the timer to zero.
        debug.reset_time()

        #This is the actual parsing of the source file using the fortpy parsers
        #NOTE: to avoid errors in pre-optimization, I will leave this like so
        #We can use some cache control on the UserContext later to speed things up. TODO
        if cache.parser().tramp.is_ssh(path):
            parser_key = "ssh"
        else:
            parser_key = "default"
        self._user_context = context.UserContext(source, self._pos,
                                                 self._orig_path, parser_key)
        self._evaluator = evaluator.Evaluator(self._user_context, self._pos)

        #Time how long all that parsing took.
        debug.speed('init')
Exemplo n.º 4
0
    def __init__(self, source=None, line=None, column=None, path=None):
        self._orig_path = path
        self.path = None if path is None else os.path.abspath(path)

        #Here we need to add support for tramp over SSH for the file that
        #is being edited. We will have cached versions of the other modules
        #in the global code cache, but we need to update the file being
        #edited in that cache so that any other buffers with reference to
        #this module being edited have the latest information.
        if source is None:
            source = cache.parser().tramp.read(path)

        #This section makes sure that the argument we have from the buffer
        #for the line number actually makes sense for the source code we have.
        lines = source.splitlines() or ['']
        if source and source[-1] == '\n':
            lines.append('')
        line = max(len(lines), 1) if line is None else line
        if not (0 < line <= len(lines)):
            raise ValueError('`line` parameter is not in a valid range.')

        #Same thing as above, except we are checking validity of column.
        line_len = len(lines[line - 1])
        column = line_len if column is None else column
        if not (0 <= column <= line_len):
            raise ValueError('`column` parameter is not in a valid range.')
        self._pos = line-1, column

        #Clear the time dependent caches. These are things we cached related
        #to completion but *not* to parsing. This is because multiple calls
        #can be made for completion of a symbol while on the same line of code.
        cache.clear_caches()
        #This is the timing module for the parsing etc. to find bottlenecks
        #and help optimize the code. It sets the timer to zero.
        debug.reset_time()

        #This is the actual parsing of the source file using the fortpy parsers
        #NOTE: to avoid errors in pre-optimization, I will leave this like so
        #We can use some cache control on the UserContext later to speed things up. TODO
        if cache.parser().tramp.is_ssh(path):
            parser_key = "ssh"
        else:
            parser_key = "default"
        self._user_context = context.UserContext(source, self._pos,
                                                 self._orig_path, parser_key)
        self._evaluator = evaluator.Evaluator(self._user_context, self._pos)

        #Time how long all that parsing took.
        debug.speed('init')