Ejemplo n.º 1
0
    def on_setBreakpoints_request(self, request):
        """
        :param SetBreakpointsRequest request:
        """
        from robotframework_debug_adapter.dap.dap_schema import SourceBreakpoint
        from robotframework_debug_adapter.dap.dap_schema import Breakpoint
        from robotframework_debug_adapter.dap.dap_schema import (
            SetBreakpointsResponseBody, )

        if self._launch_process is None:
            # Just acknowledge that no breakpoints are valid.
            breakpoints = []
            if request.arguments.breakpoints:
                for bp in request.arguments.breakpoints:
                    source_breakpoint = SourceBreakpoint(**bp)
                    breakpoints.append(
                        Breakpoint(
                            verified=False,
                            line=source_breakpoint.line,
                            source=request.arguments.source,
                        ).to_dict())

            self.write_to_client_message(
                base_schema.build_response(
                    request,
                    kwargs=dict(body=SetBreakpointsResponseBody(
                        breakpoints=breakpoints)),
                ))
            return

        self._launch_process.resend_request_to_robot(request)
Ejemplo n.º 2
0
    def set_breakpoints(self, target, lines):
        import os.path
        from robotframework_debug_adapter.dap.dap_schema import SetBreakpointsRequest
        from robotframework_debug_adapter.dap.dap_schema import SetBreakpointsArguments
        from robotframework_debug_adapter.dap.dap_schema import Source
        from robotframework_debug_adapter.dap.dap_schema import SourceBreakpoint
        from robotframework_debug_adapter.dap.dap_schema import SetBreakpointsResponse

        if isinstance(lines, int):
            lines = (lines,)
        assert isinstance(lines, (list, tuple))

        self.write(
            SetBreakpointsRequest(
                SetBreakpointsArguments(
                    source=Source(name=os.path.basename(target), path=target),
                    lines=lines,
                    breakpoints=[
                        SourceBreakpoint(line=line).to_dict() for line in lines
                    ],
                )
            )
        )
        response = self.read(SetBreakpointsResponse)
        assert len(response.body.breakpoints) == len(lines)
Ejemplo n.º 3
0
    def on_setBreakpoints_request(self, request):
        from robotframework_debug_adapter.dap.dap_schema import SourceBreakpoint
        from robotframework_debug_adapter.dap.dap_schema import Breakpoint
        from robotframework_debug_adapter.dap.dap_schema import (
            SetBreakpointsResponseBody, )
        from robotframework_debug_adapter.dap import dap_base_schema
        from robotframework_debug_adapter import file_utils
        from robotframework_debug_adapter.debugger_impl import RobotBreakpoint
        from robocode_ls_core.robotframework_log import get_logger

        log = get_logger("robotframework_debug_adapter.run_robot__main__.py")

        # Just acknowledge that no breakpoints are valid.

        breakpoints = []
        robot_breakpoints = []
        source = request.arguments.source
        path = source.path
        filename = file_utils.norm_file_to_server(path)
        log.info("Normalized %s to %s", path, filename)

        if request.arguments.breakpoints:

            for bp in request.arguments.breakpoints:
                source_breakpoint = SourceBreakpoint(**bp)
                breakpoints.append(
                    Breakpoint(verified=True,
                               line=source_breakpoint.line,
                               source=source).to_dict())
                robot_breakpoints.append(
                    RobotBreakpoint(source_breakpoint.line))

        if self._debugger_impl:
            self._debugger_impl.set_breakpoints(filename, robot_breakpoints)
        else:
            if robot_breakpoints:
                get_log().info("Unable to set breakpoints (no debug mode).")

        self.write_message(
            dap_base_schema.build_response(
                request,
                kwargs=dict(body=SetBreakpointsResponseBody(
                    breakpoints=breakpoints)),
            ))
Ejemplo n.º 4
0
    def on_setBreakpoints_request(self, request):
        from robotframework_debug_adapter.dap.dap_schema import SourceBreakpoint
        from robotframework_debug_adapter.dap.dap_schema import Breakpoint
        from robotframework_debug_adapter.dap.dap_schema import (
            SetBreakpointsResponseBody,
        )
        from robotframework_debug_adapter.dap import dap_base_schema
        from robotframework_debug_adapter import file_utils
        from robotframework_debug_adapter.debugger_impl import RobotBreakpoint

        # Just acknowledge that no breakpoints are valid.

        breakpoints = []
        robot_breakpoints = []
        source = request.arguments.source
        path = source.path
        if IS_PY2:
            path = path.encode(file_utils.file_system_encoding)
        filename = file_utils.norm_file_to_server(path)

        if request.arguments.breakpoints:

            for bp in request.arguments.breakpoints:
                source_breakpoint = SourceBreakpoint(**bp)
                breakpoints.append(
                    Breakpoint(
                        verified=True, line=source_breakpoint.line, source=source
                    ).to_dict()
                )
                robot_breakpoints.append(RobotBreakpoint(source_breakpoint.line))

        if self._debugger_impl:
            self._debugger_impl.set_breakpoints(filename, robot_breakpoints)
        else:
            if robot_breakpoints:
                get_log().info("Unable to set breakpoints (no debug mode).")

        self.write_message(
            dap_base_schema.build_response(
                request,
                kwargs=dict(body=SetBreakpointsResponseBody(breakpoints=breakpoints)),
            )
        )