def run(code, view, filename='untitled'): lines = set() errorUnderlines = [ ] # leave this here for compatibility with original plugin errorMessages = {} warningUnderlines = [] warningMessages = {} checker = LintChecker() checker.lint_text(code, filename) def addMessage(lineno, message, type): message = message.capitalize() errors = errorMessages if type == LintChecker.ERROR_TYPE_ILLEGAL else warningMessages if lineno in errors: errors[lineno].append(message) else: errors[lineno] = [message] def underlineRange(lineno, position, type): line = view.full_line(view.text_point(lineno, 0)) position += line.begin() underlines = errorUnderlines if type == LintChecker.ERROR_TYPE_ILLEGAL else warningUnderlines underlines.append(sublime.Region(position)) for error in checker.errors: lineno = error['lineNum'] - 1 # ST2 wants zero-based numbers lines.add(lineno) addMessage(lineno, error['message'], error['type']) for position in error.get('positions', []): underlineRange(lineno, position, error['type']) return lines, errorUnderlines, [], warningUnderlines, errorMessages, {}, warningMessages
def run(code, view, filename='untitled'): lines = set() errorUnderlines = [] # leave this here for compatibility with original plugin errorMessages = {} warningUnderlines = [] warningMessages = {} checker = LintChecker() checker.lint_text(code, filename) def addMessage(lineno, message, type): message = message.capitalize() errors = errorMessages if type == LintChecker.ERROR_TYPE_ILLEGAL else warningMessages if lineno in errors: errors[lineno].append(message) else: errors[lineno] = [message] def underlineRange(lineno, position, type): line = view.full_line(view.text_point(lineno, 0)) position += line.begin() underlines = errorUnderlines if type == LintChecker.ERROR_TYPE_ILLEGAL else warningUnderlines underlines.append(sublime.Region(position)) for error in checker.errors: lineno = error['lineNum'] - 1 # ST2 wants zero-based numbers lines.add(lineno) addMessage(lineno, error['message'], error['type']) for position in error.get('positions', []): underlineRange(lineno, position, error['type']) return lines, errorUnderlines, [], warningUnderlines, errorMessages, {}, warningMessages
def built_in_check(self, view, code, filename): checker = LintChecker(view) checker.lint_text(code, filename) return checker.errors