Title: [152748] trunk/Tools
Revision
152748
Author
[email protected]
Date
2013-07-16 17:12:22 -0700 (Tue, 16 Jul 2013)

Log Message

check-webkit-style: "using namespace foo;" should be flagged as an error only in headers
https://bugs.webkit.org/show_bug.cgi?id=118755

Reviewed by Ryosuke Niwa.

Fix r152719 to check "using namespace foo;" only in headers.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_using_namespace):
(check_style):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_using_namespace):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (152747 => 152748)


--- trunk/Tools/ChangeLog	2013-07-16 23:24:33 UTC (rev 152747)
+++ trunk/Tools/ChangeLog	2013-07-17 00:12:22 UTC (rev 152748)
@@ -1,3 +1,18 @@
+2013-07-16  Kwang Yul Seo  <[email protected]>
+
+        check-webkit-style: "using namespace foo;" should be flagged as an error only in headers
+        https://bugs.webkit.org/show_bug.cgi?id=118755
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix r152719 to check "using namespace foo;" only in headers.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_using_namespace):
+        (check_style):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (WebKitStyleTest.test_using_namespace):
+
 2013-07-16  Christophe Dumez  <[email protected]>
 
         Get rid of multiple inheritance support from the bindings generators

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (152747 => 152748)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2013-07-16 23:24:33 UTC (rev 152747)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2013-07-17 00:12:22 UTC (rev 152748)
@@ -2161,19 +2161,18 @@
           "Use 'using namespace std;' instead of 'using std::%s;'." % method_name)
 
 
-def check_using_namespace(clean_lines, line_number, file_state, error):
+def check_using_namespace(clean_lines, line_number, file_extension, error):
     """Looks for 'using namespace foo;' which should be removed.
 
     Args:
       clean_lines: A CleansedLines instance containing the file.
       line_number: The number of the line to check.
-      file_state: A _FileState instance which maintains information about
-                  the state of things in the file.
+      file_extension: The extension (dot not included) of the file.
       error: The function to call with any errors found.
     """
 
-    # This check doesn't apply to C or Objective-C implementation files.
-    if file_state.is_c_or_objective_c():
+    # This check applies only to headers.
+    if file_extension != 'h':
         return
 
     line = clean_lines.elided[line_number]  # Get rid of comments and strings.
@@ -2670,7 +2669,7 @@
     check_namespace_indentation(clean_lines, line_number, file_extension, file_state, error)
     check_directive_indentation(clean_lines, line_number, file_state, error)
     check_using_std(clean_lines, line_number, file_state, error)
-    check_using_namespace(clean_lines, line_number, file_state, error)
+    check_using_namespace(clean_lines, line_number, file_extension, error)
     check_max_min_macros(clean_lines, line_number, file_state, error)
     check_ctype_functions(clean_lines, line_number, file_state, error)
     check_switch_indentation(clean_lines, line_number, error)

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (152747 => 152748)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2013-07-16 23:24:33 UTC (rev 152747)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2013-07-17 00:12:22 UTC (rev 152748)
@@ -4495,7 +4495,7 @@
             'using namespace foo;',
             "Do not use 'using namespace foo;'."
             "  [build/using_namespace] [4]",
-            'foo.cpp')
+            'foo.h')
 
     def test_max_macro(self):
         self.assert_lint(
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to