From e657e7a684ca80c4919a8a5157ab197fafe03f84 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Thu, 26 Apr 2012 18:14:06 +0200 Subject: [PATCH] Make capp_lint use a single code base for command line and SublimeLinter --- Tools/capp_lint/capp_lint | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tools/capp_lint/capp_lint b/Tools/capp_lint/capp_lint index ed3b23815b..85fc96fb21 100755 --- a/Tools/capp_lint/capp_lint +++ b/Tools/capp_lint/capp_lint @@ -254,7 +254,8 @@ class LintChecker(object): TEXT_ERROR_SINGLE_FILE_TEMPLATE = Template(u'$lineNum: $message.\n+$line\n') TEXT_ERROR_MULTI_FILE_TEMPLATE = Template(u'$filename:$lineNum: $message.\n+$line\n') - def __init__(self, basedir='', var_declarations=VAR_DECLARATIONS_SINGLE, verbose=False): + def __init__(self, view, basedir='', var_declarations=VAR_DECLARATIONS_SINGLE, verbose=False): + self.view = view self.basedir = unicode(basedir, 'utf-8') self.errors = [] self.errorFiles = [] @@ -274,6 +275,14 @@ class LintChecker(object): def run_line_checks(self): for check in self.LINE_CHECKLIST: + option = check.get('option') + + if option: + default = check.get('optionDefault', False) + + if self.view and not self.view.settings().get(option, default): + continue + line = self.line lineFilter = check.get('filter') @@ -973,7 +982,7 @@ if __name__ == '__main__': print usage.replace('%prog', os.path.basename(sys.argv[0])) sys.exit(0) - checker = LintChecker(basedir=basedir, var_declarations=LintChecker.VAR_DECLARATIONS.index(options.var_declarations), verbose=options.verbose) + checker = LintChecker(basedir=basedir, view=None, var_declarations=LintChecker.VAR_DECLARATIONS.index(options.var_declarations), verbose=options.verbose) pathsToCheck = [] for filename in filenames: