示例#1
0
    def run(self, launch_browser=False, restart=False):
        # Define new session with DBGp protocol
        S.SESSION = protocol.Protocol()
        S.SESSION_BUSY = False
        S.BREAKPOINT_EXCEPTION = None
        S.BREAKPOINT_ROW = None
        S.CONTEXT_DATA.clear()
        async_session = session.SocketHandler(session.ACTION_WATCH,
                                              check_watch_view=True)
        async_session.start()
        # Remove temporary breakpoint
        if S.BREAKPOINT_RUN is not None and S.BREAKPOINT_RUN[
                'filename'] in S.BREAKPOINT and S.BREAKPOINT_RUN[
                    'lineno'] in S.BREAKPOINT[S.BREAKPOINT_RUN['filename']]:
            self.window.active_view().run_command(
                'xdebug_breakpoint', {
                    'rows': [S.BREAKPOINT_RUN['lineno']],
                    'filename': S.BREAKPOINT_RUN['filename']
                })
        S.BREAKPOINT_RUN = None
        # Set debug layout
        self.window.run_command('xdebug_layout')
        # Launch browser
        if launch_browser or (config.get_value(S.KEY_LAUNCH_BROWSER)
                              and not restart):
            util.launch_browser()

        # Start thread which will run method that listens for response on configured port
        threading.Thread(target=self.listen).start()
示例#2
0
    def on_done(self, line):
        # Split command and arguments, define arguments when only command is defined.
        if ' ' in line:
            command, args = line.split(' ', 1)
        else:
            command, args = line, ''

        async_session = session.SocketHandler(session.ACTION_USER_EXECUTE,
                                              command=command,
                                              args=args)
        async_session.start()
示例#3
0
 def run(self, close_windows=False, launch_browser=False, restart=False):
     try:
         S.SESSION.clear()
     except:
         pass
     finally:
         S.SESSION = None
         S.SESSION_BUSY = False
         S.BREAKPOINT_EXCEPTION = None
         S.BREAKPOINT_ROW = None
         S.CONTEXT_DATA.clear()
         async_session = session.SocketHandler(session.ACTION_WATCH,
                                               check_watch_view=True)
         async_session.start()
         # Remove temporary breakpoint
         if S.BREAKPOINT_RUN is not None and S.BREAKPOINT_RUN[
                 'filename'] in S.BREAKPOINT and S.BREAKPOINT_RUN[
                     'lineno'] in S.BREAKPOINT[
                         S.BREAKPOINT_RUN['filename']]:
             self.window.active_view().run_command(
                 'xdebug_breakpoint', {
                     'rows': [S.BREAKPOINT_RUN['lineno']],
                     'filename': S.BREAKPOINT_RUN['filename']
                 })
         S.BREAKPOINT_RUN = None
     # Launch browser
     if launch_browser or (config.get_value(S.KEY_LAUNCH_BROWSER)
                           and not restart):
         util.launch_browser()
     # Close or reset debug layout
     if close_windows or config.get_value(S.KEY_CLOSE_ON_STOP):
         if config.get_value(S.KEY_DISABLE_LAYOUT):
             self.window.run_command('xdebug_layout',
                                     {'close_windows': True})
         else:
             self.window.run_command('xdebug_layout', {'restore': True})
     else:
         self.window.run_command('xdebug_layout')
     # Render breakpoint markers
     V.render_regions()
示例#4
0
    def run(self,
            edit,
            rows=None,
            condition=None,
            enabled=None,
            filename=None):
        # Get filename in current view and check if is a valid filename
        if filename is None:
            filename = self.view.file_name()
        if not filename or not os.path.isfile(filename):
            return

        # Add entry for file in breakpoint data
        if filename not in S.BREAKPOINT:
            S.BREAKPOINT[filename] = {}

        # When no rows are defined, use selected rows (line numbers), filtering empty rows
        if rows is None:
            rows = V.region_to_rows(self.view.sel(), filter_empty=True)

        # Loop through rows
        for row in rows:
            expression = None
            if condition is not None and len(condition.strip()) > 0:
                expression = condition
            # Check if breakpoint exists
            breakpoint_exists = row in S.BREAKPOINT[filename]
            # Disable/Remove breakpoint
            if breakpoint_exists:
                if S.BREAKPOINT[filename][row][
                        'id'] is not None and session.is_connected(
                            show_status=True):
                    async_session = session.SocketHandler(
                        session.ACTION_REMOVE_BREAKPOINT,
                        breakpoint_id=S.BREAKPOINT[filename][row]['id'])
                    async_session.start()
                if enabled is False:
                    S.BREAKPOINT[filename][row]['enabled'] = False
                elif enabled is None:
                    del S.BREAKPOINT[filename][row]
            # Add/Enable breakpoint
            if not breakpoint_exists or enabled is True:
                if row not in S.BREAKPOINT[filename]:
                    S.BREAKPOINT[filename][row] = {
                        'id': None,
                        'enabled': True,
                        'expression': expression
                    }
                else:
                    S.BREAKPOINT[filename][row]['enabled'] = True
                    if condition is not None:
                        S.BREAKPOINT[filename][row]['expression'] = expression
                    else:
                        expression = S.BREAKPOINT[filename][row]['expression']
                if session.is_connected(show_status=True):
                    async_session = session.SocketHandler(
                        session.ACTION_SET_BREAKPOINT,
                        filename=filename,
                        lineno=row,
                        expression=expression)
                    async_session.start()

        # Render breakpoint markers
        V.render_regions()

        # Update breakpoint list
        try:
            if V.has_debug_view(V.TITLE_WINDOW_BREAKPOINT):
                V.show_content(V.DATA_BREAKPOINT)
        except:
            pass

        # Save breakpoint data to file
        util.save_breakpoint_data()
示例#5
0
 def update_view(self):
     async_session = session.SocketHandler(session.ACTION_WATCH,
                                           check_watch_view=True)
     async_session.start()
     # Save watch data to file
     util.save_watch_data()
示例#6
0
 def on_done(self, expression):
     async_session = session.SocketHandler(session.ACTION_EVALUATE,
                                           expression=expression)
     async_session.start()
示例#7
0
 def run(self):
     async_session = session.SocketHandler(session.ACTION_STATUS)
     async_session.start()
示例#8
0
 def run(self, command=None):
     async_session = session.SocketHandler(session.ACTION_EXECUTE,
                                           command=command)
     async_session.start()
示例#9
0
    def connected(self):
        sublime.set_timeout(
            lambda: sublime.status_message('Xdebug: Connected'), 100)

        async_session = session.SocketHandler(session.ACTION_INIT)
        async_session.start()