def run(self, *args): view = get_current_active_view() view_error_lines = erroneous_lines[view.id()] prev_error_line = view_error_lines.previous() path = "%s:%d" % (view.file_name(), prev_error_line + 1) view.window().open_file(path, sublime.ENCODED_POSITION)
def check(view=None): """Perform a linter check on the view """ if view is None: view = get_current_active_view() if not get_setting('python_linting', view, True): return filename = file_or_buffer_name(view) proxy = proxy_for(view) if not proxy: return lint_settings = { 'pep8': get_setting('pep8', view, default_value=True), 'pep8_ignore': get_setting('pep8_ignore', view, default_value=[]), 'pep8_max_line_length': get_setting( 'pep8_max_line_length', view, default_value=None), 'pyflakes_ignore': get_setting( 'pyflakes_ignore', view, default_value=[]), } code = view.substr(sublime.Region(0, view.size())) encoding = view.encoding() if encoding.lower() == "undefined": encoding = "utf-8" errors = proxy.check_syntax(code, encoding, lint_settings, filename) try: if errors: errors = pickle.loads(errors.data) vid = view.id() lines = set() # leave this here for compatibility with original plugin error_underlines[vid] = [] error_messages[vid] = {} violation_underlines[vid] = [] violation_messages[vid] = {} warning_underlines[vid] = [] warning_messages[vid] = {} if errors: parse_errors(view, errors, lines, vid) erroneous_lines[vid] = ListWithPointer(sorted(set( list(error_messages[vid].keys()) + list(violation_messages[vid].keys()) + list(warning_messages[vid].keys())))) # the result can be a list of errors, or single syntax exception try: _update_lint_marks(view, lines) except Exception as e: print('SublimePythonIDE: Add lint marks failed\n{0}'.format(e)) update_statusbar(view) except Exception as error: print("SublimePythonIDE: No server response\n{0}".format(error))
def check(view=None): """Perform a linter check on the view """ if view is None: view = get_current_active_view() if not get_setting('python_linting', view, True): return filename = file_or_buffer_name(view) proxy = proxy_for(view) if not proxy: return lint_settings = { 'pep8': get_setting('pep8', view, default_value=True), 'pep8_ignore': get_setting('pep8_ignore', view, default_value=[]), 'pep8_max_line_length': get_setting('pep8_max_line_length', view, default_value=None), 'pyflakes_ignore': get_setting('pyflakes_ignore', view, default_value=[]), } code = view.substr(sublime.Region(0, view.size())) encoding = view.encoding() if encoding.lower() == "undefined": encoding = "utf-8" errors = proxy.check_syntax(code, encoding, lint_settings, filename) try: if errors: errors = pickle.loads(errors.data) vid = view.id() lines = set() # leave this here for compatibility with original plugin error_underlines[vid] = [] error_messages[vid] = {} violation_underlines[vid] = [] violation_messages[vid] = {} warning_underlines[vid] = [] warning_messages[vid] = {} if errors: parse_errors(view, errors, lines, vid) erroneous_lines[vid] = ListWithPointer( sorted( set( list(error_messages[vid].keys()) + list(violation_messages[vid].keys()) + list(warning_messages[vid].keys())))) # the result can be a list of errors, or single syntax exception try: _update_lint_marks(view, lines) except Exception as e: print('SublimePythonIDE: Add lint marks failed\n{0}'.format(e)) update_statusbar(view) except Exception as error: print("SublimePythonIDE: No server response\n{0}".format(error))
def run(self, *args): view = get_current_active_view() override_view_setting('pep8', True, view) check(view)