Title: [100678] trunk/Tools
Revision
100678
Author
caio.olive...@openbossa.org
Date
2011-11-17 14:34:55 -0800 (Thu, 17 Nov 2011)

Log Message

Make check-webkit-style accept xxx_p.h as a primary header for xxx.cpp for Qt's sake
https://bugs.webkit.org/show_bug.cgi?id=72620

Reviewed by David Levin.

Qt's convention of keeping private (but exposed) API suffixed by "_p.h" but not
adding the suffix the cpp file. One example of false positive
https://bugs.webkit.org/show_bug.cgi?id=72319#c12.

* Scripts/webkitpy/style/checkers/cpp.py: accept headers ending with _p as primary if its
basename contains the cpp's basename.
* Scripts/webkitpy/style/checkers/cpp_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (100677 => 100678)


--- trunk/Tools/ChangeLog	2011-11-17 22:34:27 UTC (rev 100677)
+++ trunk/Tools/ChangeLog	2011-11-17 22:34:55 UTC (rev 100678)
@@ -1,3 +1,18 @@
+2011-11-17  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
+
+        Make check-webkit-style accept xxx_p.h as a primary header for xxx.cpp for Qt's sake
+        https://bugs.webkit.org/show_bug.cgi?id=72620
+
+        Reviewed by David Levin.
+
+        Qt's convention of keeping private (but exposed) API suffixed by "_p.h" but not
+        adding the suffix the cpp file. One example of false positive
+        https://bugs.webkit.org/show_bug.cgi?id=72319#c12.
+
+        * Scripts/webkitpy/style/checkers/cpp.py: accept headers ending with _p as primary if its
+        basename contains the cpp's basename.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+
 2011-11-17  Eric Seidel  <e...@webkit.org>
 
         Move check-webkit-style's guts into webkitpy/style/main.py

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-11-17 22:34:27 UTC (rev 100677)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-11-17 22:34:55 UTC (rev 100678)
@@ -2605,8 +2605,13 @@
     include_base = FileInfo(include).base_name()
 
     # If we haven't encountered a primary header, then be lenient in checking.
-    if not include_state.visited_primary_section() and target_base.find(include_base) != -1:
-        return _PRIMARY_HEADER
+    if not include_state.visited_primary_section():
+        if target_base.find(include_base) != -1:
+            return _PRIMARY_HEADER
+        # Qt private APIs use _p.h suffix.
+        if include_base.find(target_base) != -1 and include_base.endswith('_p'):
+            return _PRIMARY_HEADER
+
     # If we already encountered a primary header, perform a strict comparison.
     # In case the two filename bases are the same then the above lenient check
     # probably was a false positive.

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-11-17 22:34:27 UTC (rev 100677)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-11-17 22:34:55 UTC (rev 100678)
@@ -2706,6 +2706,11 @@
                          classify_include('foo.cpp',
                                           'moc_foo.cpp',
                                           False, include_state))
+        # Qt private APIs use _p.h suffix.
+        self.assertEqual(cpp_style._PRIMARY_HEADER,
+                         classify_include('foo.cpp',
+                                          'foo_p.h',
+                                          False, include_state))
         # Tricky example where both includes might be classified as primary.
         self.assert_language_rules_check('ScrollbarThemeWince.cpp',
                                          '#include "config.h"\n'
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to