Revision: 192
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=192&view=rev
Author: matthiasmiller
Date: 2008-04-25 14:16:20 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Slight speedup for linting.
Modified Paths:
--------------
trunk/pyjsl/lint.py
Modified: trunk/pyjsl/lint.py
===================================================================
--- trunk/pyjsl/lint.py 2008-04-23 19:07:41 UTC (rev 191)
+++ trunk/pyjsl/lint.py 2008-04-25 21:16:20 UTC (rev 192)
@@ -245,17 +245,17 @@
if not node.atom in imports:
report(node, 'undeclared_identifier')
+def _warn_or_declare(scope, name, node, report):
+ other = scope.get_identifier(name)
+ if other and other.kind == tok.FUNCTION and name in other.fn_args:
+ report(node, 'var_hides_arg')
+ elif other:
+ report(node, 'redeclared_var')
+ else:
+ scope.add_declaration(name, node)
+
def _lint_node(node, visitors, report, scope):
- def warn_or_declare(name, node):
- other = scope.get_identifier(name)
- if other and other.kind == tok.FUNCTION and name in other.fn_args:
- report(node, 'var_hides_arg')
- elif other:
- report(node, 'redeclared_var')
- else:
- scope.add_declaration(name, node)
-
# Let the visitors warn.
for kind in (node.kind, (node.kind, node.opcode)):
if kind in visitors:
@@ -275,7 +275,7 @@
# Push function identifiers
if node.kind == tok.FUNCTION:
if node.fn_name:
- warn_or_declare(node.fn_name, node)
+ _warn_or_declare(scope, node.fn_name, node, report)
scope = scope.add_scope(node)
for var_name in node.fn_args:
scope.add_declaration(var_name, node)
@@ -285,7 +285,7 @@
scope = scope.add_scope(node)
if node.parent and node.parent.kind == tok.VAR:
- warn_or_declare(node.atom, node)
+ _warn_or_declare(scope, node.atom, node, report)
for child in node.kids:
if child:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|