Title: [220367] trunk/Tools
Revision
220367
Author
[email protected]
Date
2017-08-07 16:25:27 -0700 (Mon, 07 Aug 2017)

Log Message

check-webkit-style: NS_ERROR_ENUM and NS_OPTIONS should not be handled as function definitions.
https://bugs.webkit.org/show_bug.cgi?id=175286

Patch by Yoshiaki Jitsukawa <[email protected]> on 2017-08-07
Reviewed by Myles C. Maxfield.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_braces.NS_ERROR_ENUM):
(WebKitStyleTest.test_braces):
(WebKitStyleTest.test_braces.NS_OPTIONS):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (220366 => 220367)


--- trunk/Tools/ChangeLog	2017-08-07 23:22:11 UTC (rev 220366)
+++ trunk/Tools/ChangeLog	2017-08-07 23:25:27 UTC (rev 220367)
@@ -1,3 +1,17 @@
+2017-08-07  Yoshiaki Jitsukawa  <[email protected]>
+
+        check-webkit-style: NS_ERROR_ENUM and NS_OPTIONS should not be handled as function definitions.
+        https://bugs.webkit.org/show_bug.cgi?id=175286
+
+        Reviewed by Myles C. Maxfield.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_braces):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (WebKitStyleTest.test_braces.NS_ERROR_ENUM):
+        (WebKitStyleTest.test_braces):
+        (WebKitStyleTest.test_braces.NS_OPTIONS):
+
 2017-08-07  Brian Burg  <[email protected]>
 
         Remove CANVAS_PATH compilation guard

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-08-07 23:22:11 UTC (rev 220366)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-08-07 23:25:27 UTC (rev 220367)
@@ -2431,7 +2431,7 @@
         # and '- (' and '+ (' for Objective-C methods.
         previous_line = get_previous_non_blank_line(clean_lines, line_number)[0]
         if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override|final|const final)\s*)?(->\s*\S+)?\s*$', previous_line)
-             or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line)
+             or search(r'\b(if|for|while|switch|else|NS_ENUM|NS_ERROR_ENUM|NS_OPTIONS)\b', previous_line)
              or regex_for_lambdas_and_blocks(previous_line, line_number, file_state, error))
             and previous_line.find('#') < 0
             and previous_line.find('- (') != 0
@@ -2440,7 +2440,7 @@
                   'This { should be at the end of the previous line')
     elif (search(r'\)\s*(((const|override|final)\s*)*\s*)?{\s*$', line)
           and line.count('(') == line.count(')')
-          and not search(r'(\s*(if|for|while|switch|NS_ENUM|@synchronized)|} @catch)\b', line)
+          and not search(r'(\s*(if|for|while|switch|NS_ENUM|NS_ERROR_ENUM|NS_OPTIONS|@synchronized)|} @catch)\b', line)
           and not regex_for_lambdas_and_blocks(line, line_number, file_state, error)
           and line.find("](") < 0
           and not match(r'\s+[A-Z_][A-Z_0-9]+\b', line)):

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-08-07 23:22:11 UTC (rev 220366)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-08-07 23:25:27 UTC (rev 220367)
@@ -4504,6 +4504,30 @@
             '    1\n'
             '};', '')
         self.assert_multi_line_lint(
+            'typedef NS_ERROR_ENUM(NSInteger, type)\n'
+            '{\n'
+            '    0,\n'
+            '    1\n'
+            '};',
+            'This { should be at the end of the previous line  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
+            'typedef NS_ERROR_ENUM(NSInteger, type) {\n'
+            '    0,\n'
+            '    1\n'
+            '};', '')
+        self.assert_multi_line_lint(
+            'typedef NS_OPTIONS(NSInteger, type)\n'
+            '{\n'
+            '    0,\n'
+            '    1\n'
+            '};',
+            'This { should be at the end of the previous line  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
+            'typedef NS_OPTIONS(NSInteger, type) {\n'
+            '    0,\n'
+            '    1\n'
+            '};', '')
+        self.assert_multi_line_lint(
             'enum class CPP11EnumClass\n'
             '{\n'
             '    Value1,\n'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to