Title: [222937] trunk/Tools
Revision
222937
Author
[email protected]
Date
2017-10-05 15:41:15 -0700 (Thu, 05 Oct 2017)

Log Message

check-webkit-style erroneously requires a space between the carrot and brace in obj-c blocks.
https://bugs.webkit.org/show_bug.cgi?id=177897

Reviewed by Dan Bernstein and Jonathan Bedard.

Remove the check for a space between ^ and {, 
as this is valid and expected Obj-C. Now check to make sure there is
no space at all between ^ and {, and also that there is a space between
the end of an argument list and the {.

* Scripts/webkitpy/style/checkers/cpp.py:
(regex_for_lambdas_and_blocks):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (222936 => 222937)


--- trunk/Tools/ChangeLog	2017-10-05 22:40:05 UTC (rev 222936)
+++ trunk/Tools/ChangeLog	2017-10-05 22:41:15 UTC (rev 222937)
@@ -1,3 +1,18 @@
+2017-10-04  Megan Gardner  <[email protected]>
+
+        check-webkit-style erroneously requires a space between the carrot and brace in obj-c blocks.
+        https://bugs.webkit.org/show_bug.cgi?id=177897
+
+        Reviewed by Dan Bernstein and Jonathan Bedard.
+
+        Remove the check for a space between ^ and {, 
+        as this is valid and expected Obj-C. Now check to make sure there is
+        no space at all between ^ and {, and also that there is a space between
+        the end of an argument list and the {.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (regex_for_lambdas_and_blocks):
+
 2017-10-05  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Run WebKit2 C API tests in GTK+ bots again after the last WebKit2 -> WebKit rename.

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-10-05 22:40:05 UTC (rev 222936)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-10-05 22:41:15 UTC (rev 222937)
@@ -1241,7 +1241,7 @@
 
 def regex_for_lambdas_and_blocks(line, line_number, file_state, error):
     cpp_result = search(r'\s\[.*?\]\s', line)
-    objc_result = search(r'(\s\^\s?\(.*?\)\s|\^\s?\{|:\^\s?\(.*?\)\s\{)', line)
+    objc_result = search(r'(\s\^\s?\(.*?\)\s?|\^\s*\{|:\^\s?\(.*?\)\s\{)', line)
     if cpp_result:
         group = cpp_result.group()
         targ_error = None
@@ -1248,7 +1248,7 @@
 
         if search(r'(\[\s|\s\]|\s,)', group):
             targ_error = [line_number, 'whitespace/brackets', 4,
-              'Extra space in capture list.']
+              'Extra space in capture list.',line]
 
         if targ_error and regex_for_lambdas_and_blocks.__last_error != targ_error:
             error(targ_error[0], targ_error[1], targ_error[2], targ_error[3])
@@ -1261,13 +1261,13 @@
 
         if search(r'(\(\s|\s\)|\s,)', group):
             targ_error = [line_number, 'whitespace/brackets', 4,
-              'Extra space in block arguments.']
-        if search(r'\^\{', group):
+              'Extra space in block arguments.',line]
+        if search(r'\^\s+\{', group):
             targ_error = [line_number, 'whitespace/brackets', 4,
-              'No space between ^ and block definition.']
+              'Extra space between ^ and block definition.',line]
         if search(r'\^\s\(', group):
             targ_error = [line_number, 'whitespace/brackets', 4,
-              'Extra space between ^ and block arguments.']
+              'Extra space between ^ and block arguments.',line]
 
         if targ_error and regex_for_lambdas_and_blocks.__last_error != targ_error:
             error(targ_error[0], targ_error[1], targ_error[2], targ_error[3])

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-10-05 22:40:05 UTC (rev 222936)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-10-05 22:41:15 UTC (rev 222937)
@@ -1942,14 +1942,16 @@
         self.assert_lint('        ^(var , var_ref) {', 'Extra space in block arguments.  [whitespace/brackets] [4]', 'foo.m')
         self.assert_lint('        ^(var,var_ref) {', 'Missing space after ,  [whitespace/comma] [3]', 'foo.m')
         self.assert_lint('        ^(var, var_ref) {', 'Place brace on its own line for function definitions.  [whitespace/braces] [4]', 'foo.cpp')
-        self.assert_lint('        ^ {', '', 'foo.m')
-        self.assert_lint('        ^{', 'No space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
+        self.assert_lint('        ^{', '', 'foo.m')
+        self.assert_lint('        ^ {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
+        self.assert_lint('        ^   {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
         self.assert_lint('        ^ (arg1, arg2) {', 'Extra space between ^ and block arguments.  [whitespace/brackets] [4]', 'foo.m')
+        self.assert_lint('        ^(arg1, arg2){', 'Missing space before {  [whitespace/braces] [5]', 'foo.m')
 
     def test_objective_c_block_as_argument(self):
         self.assert_lint('        withLambda:^(var, var_ref) {', '', 'foo.mm')
-        self.assert_lint('        withLambda:^ {', '', 'foo.m')
-        self.assert_lint('        withLambda:^{', 'No space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
+        self.assert_lint('        withLambda:^{', '', 'foo.m')
+        self.assert_lint('        withLambda:^ {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
 
     def test_spacing_around_else(self):
         self.assert_lint('}else {', 'Missing space before else'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to