Example #1
0
def command_setup(self):
    """
    Series of common setup tasks across all commands

    self: WindowCommand context

    returns True for success, False for an error
    """

    try:
        success = True

        self.view = self.window.active_view()
        self.view.filename = self.view.file_name()

        config = backend({
            'filename': self.view.filename,
            'command': 'get-config'
        })

        self.window.config = json.loads(config)
        p('parsed config from backend', self.window.config)

        return success
    except Exception as e:
        p(e)
        show_error(e, True)

    return False
Example #2
0
def command_setup(self):
    """
    Series of common setup tasks across all commands

    self: WindowCommand context

    returns True for success, False for an error
    """

    try:
        success = True

        self.view = self.window.active_view()
        self.view.filename = self.view.file_name()

        config = backend({
            'filename': self.view.filename,
            'command': 'get-config'
        })

        self.window.config = json.loads(config)
        p('parsed config from backend', self.window.config)

        return success
    except Exception as e:
        p(e)
        show_error(e, True)

    return False
Example #3
0
    def get_results(self):
        """
        Asks the node tool for the dependents of the current module
        """
        tree = backend({'filename': self.view.filename, 'command': 'get-tree'})

        tree = tree.replace(self.window.config['directory'] + '/', '')

        data = json.loads(tree)
        return json.dumps(data, indent=4)
Example #4
0
    def get_drivers(self):
        """
        Asks the node tool for the drivers of the current module
        """
        args = {'filename': self.view.filename, 'command': 'find-drivers'}

        drivers = [d for d in backend(args).split('\n') if d]

        p(len(drivers), 'drivers found:\n' + '\n'.join(drivers))

        return drivers
Example #5
0
    def run(self):
        p('Extracted click position', self.view.click_position)

        file_to_open = backend({
            'filename': self.view.filename,
            'click_position': self.view.click_position,
            'command': 'jump-to-definition'
        }).strip()

        p('After jump to definition lookup', file_to_open)

        self.open_file(file_to_open)
Example #6
0
    def run(self):
        if not super(GetPathCommand, self).run():
            return

        path = backend({
            'filename': self.view.filename,
            'command': 'get-path'
        }).strip()

        p('Path:', path)

        sublime.set_clipboard(path)
Example #7
0
    def get_results(self):
        """
        Asks the node tool for the dependents of the current module
        """
        tree = backend({
            'filename': self.view.filename,
            'command': 'get-tree'
        })

        tree = tree.replace(self.window.config['directory'] + '/', '')

        data = json.loads(tree)
        return json.dumps(data, indent=4)
Example #8
0
    def get_drivers(self):
        """
        Asks the node tool for the drivers of the current module
        """
        args = {
            'filename': self.view.filename,
            'command': 'find-drivers'
        }

        drivers = [d for d in backend(args).split('\n') if d]

        p(len(drivers), 'drivers found:\n' + '\n'.join(drivers))

        return drivers
Example #9
0
    def get_callers(self, function_name):
        """
        Asks the node tool for the drivers of the current module
        """
        args = {
            'filename': self.view.filename,
            'path': function_name,
            'command': 'find-callers'
        }

        fetch_time = time.time()

        callers = [c for c in backend(args) if c]

        p('Fetch time:', time.time() - fetch_time)
        p(len(callers), 'callers found:\n' + '\n'.join(callers))

        return callers
Example #10
0
    def get_callers(self, function_name):
        """
        Asks the node tool for the drivers of the current module
        """
        args = {
            'filename': self.view.filename,
            'path': function_name,
            'command': 'find-callers'
        }

        fetch_time = time.time()

        callers = [c for c in backend(args) if c]

        p('Fetch time:', time.time() - fetch_time)
        p(len(callers), 'callers found:\n' + '\n'.join(callers))

        return callers
Example #11
0
    def run(self):
        """
        Jumps to the file identified by the string under the cursor
        """

        selection = self.view.selection

        p('Extracted Selection', selection)

        file_to_open = backend({
            'filename': self.view.filename,
            'path': selection.get('line'),
            'lookup_position': selection.get('clicked_position'),
            'command': 'lookup'
        }).strip()

        p('After cabinet lookup', file_to_open)

        self.open_file(file_to_open)
Example #12
0
    def run(self):
        """
        Jumps to the file identified by the string under the cursor
        """

        selection = self.view.selection

        p('Extracted Selection', selection)

        file_to_open = backend({
            'filename':
            self.view.filename,
            'path':
            selection.get('line'),
            'lookup_position':
            selection.get('clicked_position'),
            'command':
            'lookup'
        }).strip()

        p('After cabinet lookup', file_to_open)

        self.open_file(file_to_open)