Exemplo n.º 1
0
    def get_completions(self, request, response):
        src = request['src']
        contents = request['contents']
        line = request['line']
        column = request['column']
        prefix = request['prefix']
        token_start_column = request['tokenStartColumn']
        flags = request['flags']

        # NOTE: there is no need to update the translation unit here.
        # libclang's completions API seamlessly takes care of unsaved content
        # without any special handling.
        translation_unit = self._get_translation_unit(src, flags)
        if translation_unit:
            if self.completion_cache is None:
                self.completion_cache = CompletionCache(
                    self.src, translation_unit)
            completions = self.completion_cache.get_completions(
                line + 1,
                token_start_column + 1,
                prefix,
                contents,
                limit=COMPLETIONS_LIMIT)
        else:
            completions = []
        response['file'] = src
        response['completions'] = completions
        response['line'] = line
        response['column'] = column
        response['prefix'] = prefix
Exemplo n.º 2
0
    def get_completions(self, request):
        contents = request['contents']
        line = request['line']
        column = request['column']
        prefix = request['prefix']
        token_start_column = request['tokenStartColumn']

        # NOTE: there is no need to update the translation unit here.
        # libclang's completions API seamlessly takes care of unsaved content
        # without any special handling.
        translation_unit = self._get_translation_unit(None)
        if translation_unit:
            if self.completion_cache is None:
                self.completion_cache = CompletionCache(
                    self.src, translation_unit, self.custom_clang_lib)
            return self.completion_cache.get_completions(
                line + 1,
                token_start_column + 1,
                prefix,
                contents,
                limit=COMPLETIONS_LIMIT)
        return []