Ejemplo n.º 1
0
class Service:
    def __init__(self, *, project_path=None):

        self.project = (Project(project_path) if project_path
                        and os.path.exists(project_path) else None)
        self._source = ""
        self.script = None

    def change_workspace(self, project_path):
        self.project = (Project(project_path) if project_path
                        and os.path.exists(project_path) else None)
        self._source = ""
        self.script = None

    def complete(self, source, row, col) -> List[JediCompletion]:
        if not self._source.startswith(source):
            self._source = source
            self.script = Script(self._source, project=self.project)

        return self.script.complete(row, col)

    def hover(self, source, row, col) -> List[JediName]:
        if not self._source.startswith(source):
            self._source = source
            self.script = Script(self._source, project=self.project)

        return self.script.help(row, col)
Ejemplo n.º 2
0
    def get_documentation(source: str,
                          *,
                          line: int,
                          column: int,
                          project: Project = None) -> Documentations:
        """complete script at following pos(line, column)

        Raises:
            ValueError: column > len(line_content)
        """

        script = Script(code=source, project=project)
        results = script.help(line=line, column=column)
        return Documentations(results)