[javascriptlint-commit] SF.net SVN: javascriptlint:[214] trunk
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2008-08-23 23:58:16
|
Revision: 214 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=214&view=rev Author: matthiasmiller Date: 2008-08-23 23:58:12 +0000 (Sat, 23 Aug 2008) Log Message: ----------- first cut at supporting jsl:pass Modified Paths: -------------- trunk/pyjsl/lint.py trunk/pyjsl/warnings.py trunk/spidermonkey/src/jsparse.c trunk/test.py trunk/tests/path_resolution/asterisk.js trunk/tests/path_resolution/is_a_file_not_dir.js trunk/tests/path_resolution/not_a_dir.js trunk/tests/path_resolution/not_a_file.js trunk/tests/path_resolution/question_mark.js Added Paths: ----------- trunk/tests/control_comments/invalid_pass.js Modified: trunk/pyjsl/lint.py =================================================================== --- trunk/pyjsl/lint.py 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/pyjsl/lint.py 2008-08-23 23:58:12 UTC (rev 214) @@ -156,9 +156,16 @@ def _lint_script(script, script_cache, lint_error, conf, import_callback): def parse_error(row, col, msg): if not msg in ('redeclared_var', 'var_hides_arg'): - parse_errors.append((jsparse.NodePos(row, col), msg)) + parse_errors.append((jsparse.NodePos(row, col), msg)) def report(node, errname): + if errname == 'empty_statement' and node.kind == tok.LC: + for pass_ in passes: + if pass_.start_pos() > node.start_pos() and \ + pass_.end_pos() < node.end_pos(): + passes.remove(pass_) + return + if errname == 'missing_break': # Find the end of the previous case/default and the beginning of # the next case/default. @@ -209,6 +216,7 @@ declares = [] import_paths = [] fallthrus = [] + passes = [] for comment in comments: cc = _parse_control_comment(comment) if cc: @@ -236,6 +244,8 @@ import_paths.append(parms) elif keyword == 'fallthru': fallthrus.append(node) + elif keyword == 'pass': + passes.append(node) else: if comment.opcode == 'c_comment': if '/*' in comment.atom or comment.atom.endswith('/'): @@ -272,6 +282,8 @@ for fallthru in fallthrus: report(fallthru, 'invalid_fallthru') + for fallthru in passes: + report(fallthru, 'invalid_pass') # Process imports by copying global declarations into the universal scope. imports |= set(conf['declarations']) Modified: trunk/pyjsl/warnings.py =================================================================== --- trunk/pyjsl/warnings.py 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/pyjsl/warnings.py 2008-08-23 23:58:12 UTC (rev 214) @@ -65,7 +65,8 @@ 'missing_option_explicit': 'the "option explicit" control comment is missing', 'partial_option_explicit': 'the "option explicit" control comment, if used, must be in the first script tag', 'dup_option_explicit': 'duplicate "option explicit" control comment', - 'invalid_fallthru': 'unexpected "fallthru" control comment' + 'invalid_fallthru': 'unexpected "fallthru" control comment', + 'invalid_pass': 'unexpected "pass" control comment' } _visitors = [] Modified: trunk/spidermonkey/src/jsparse.c =================================================================== --- trunk/spidermonkey/src/jsparse.c 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/spidermonkey/src/jsparse.c 2008-08-23 23:58:12 UTC (rev 214) @@ -1519,7 +1519,9 @@ if (tt == TOK_ERROR) return NULL; - pn->pn_pos.end = CURRENT_TOKEN(ts).pos.end; + /* Set the LC's end position to the start of the RC. The stream is + * guaranteed to have a lookahead because of the peek above. */ + pn->pn_pos.end = ts->tokens[(ts->cursor+ts->lookahead) & NTOKENS_MASK].pos.begin; return pn; } Modified: trunk/test.py =================================================================== --- trunk/test.py 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/test.py 2008-08-23 23:58:12 UTC (rev 214) @@ -24,7 +24,7 @@ for i in range(0, len(lines)): for warning in regexp.findall(lines[i]): # TODO: implement these - unimpl_warnings = ('ambiguous_newline', 'dup_option_explicit', 'invalid_pass', + unimpl_warnings = ('ambiguous_newline', 'dup_option_explicit', 'missing_semicolon' ) if not warning in unimpl_warnings: Added: trunk/tests/control_comments/invalid_pass.js =================================================================== --- trunk/tests/control_comments/invalid_pass.js (rev 0) +++ trunk/tests/control_comments/invalid_pass.js 2008-08-23 23:58:12 UTC (rev 214) @@ -0,0 +1,2 @@ +/*jsl:option explicit*/ +/*jsl:pass*/ /*warning:invalid_pass*/ Modified: trunk/tests/path_resolution/asterisk.js =================================================================== --- trunk/tests/path_resolution/asterisk.js 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/tests/path_resolution/asterisk.js 2008-08-23 23:58:12 UTC (rev 214) @@ -1,3 +1,2 @@ /*conf:+process unknown_dir/a*b */ /*conf_error:unable to resolve path: unknown_dir/a*b*/ -/*jsl:pass*/ Modified: trunk/tests/path_resolution/is_a_file_not_dir.js =================================================================== --- trunk/tests/path_resolution/is_a_file_not_dir.js 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/tests/path_resolution/is_a_file_not_dir.js 2008-08-23 23:58:12 UTC (rev 214) @@ -1,3 +1,2 @@ /*conf:+process file/ */ /*conf_error:unable to resolve path: file/*/ -/*jsl:pass*/ Modified: trunk/tests/path_resolution/not_a_dir.js =================================================================== --- trunk/tests/path_resolution/not_a_dir.js 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/tests/path_resolution/not_a_dir.js 2008-08-23 23:58:12 UTC (rev 214) @@ -1,3 +1,2 @@ /*conf:+process not_a_dir*/ /*conf_error:unable to resolve path: not_a_dir*/ -/*jsl:pass*/ Modified: trunk/tests/path_resolution/not_a_file.js =================================================================== --- trunk/tests/path_resolution/not_a_file.js 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/tests/path_resolution/not_a_file.js 2008-08-23 23:58:12 UTC (rev 214) @@ -1,3 +1,2 @@ /*conf:+process not_a_file*/ /*conf_error:unable to resolve path: not_a_file*/ -/*jsl:pass*/ Modified: trunk/tests/path_resolution/question_mark.js =================================================================== --- trunk/tests/path_resolution/question_mark.js 2008-08-23 23:14:10 UTC (rev 213) +++ trunk/tests/path_resolution/question_mark.js 2008-08-23 23:58:12 UTC (rev 214) @@ -1,3 +1,2 @@ /*conf:+process unknown_dir/a?b */ /*conf_error:unable to resolve path: unknown_dir/a?b*/ -/*jsl:pass*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |