Title: [252433] trunk/Tools
- Revision
- 252433
- Author
- [email protected]
- Date
- 2019-11-13 14:56:54 -0800 (Wed, 13 Nov 2019)
Log Message
check-webkit-style: fix false errors for obj-c method calls in range-based for statements using colon syntax
https://bugs.webkit.org/show_bug.cgi?id=204142
Reviewed by Jonathan Bedard.
Allow for the existance of an obj-c method call in a range-based for statement that also uses colons.
Do not allow colons between square brackets to trigger the error.
Also add a test for this specific case.
* Scripts/webkitpy/style/checkers/cpp.py:
(check_spacing):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_spacing):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (252432 => 252433)
--- trunk/Tools/ChangeLog 2019-11-13 22:47:24 UTC (rev 252432)
+++ trunk/Tools/ChangeLog 2019-11-13 22:56:54 UTC (rev 252433)
@@ -1,3 +1,19 @@
+2019-11-13 Megan Gardner <[email protected]>
+
+ check-webkit-style: fix false errors for obj-c method calls in range-based for statements using colon syntax
+ https://bugs.webkit.org/show_bug.cgi?id=204142
+
+ Reviewed by Jonathan Bedard.
+
+ Allow for the existance of an obj-c method call in a range-based for statement that also uses colons.
+ Do not allow colons between square brackets to trigger the error.
+ Also add a test for this specific case.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_spacing):
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (WebKitStyleTest.test_spacing):
+
2019-11-13 Aakash Jain <[email protected]>
[EWS] Parse jsc_results.json for JSC tests
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (252432 => 252433)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2019-11-13 22:47:24 UTC (rev 252432)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2019-11-13 22:56:54 UTC (rev 252433)
@@ -1978,13 +1978,14 @@
# there should either be zero or one spaces inside the parens.
# We don't want: "if ( foo)" or "if ( foo )".
# Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed.
+ # Exception: "for (foo n in [foo bar:baz])" is allowed because of obj-c method calls
matched = search(r'\b(?P<statement>if|for|while|switch)\s*\((?P<remainder>.*)$', line)
if matched:
statement = matched.group('statement')
condition, rest = up_to_unmatched_closing_paren(matched.group('remainder'))
if condition is not None:
- if statement == 'for' and search(r'(?:[^ :]:[^:]|[^:]:[^ :])', condition):
- error(line_number, 'whitespace/colon', 4, 'Missing space around : in range-based for statement')
+ if statement == 'for' and search(r'(?:[^ :]:[^:]|[^:]:[^ :])', condition) and not search(r'\[[^\]]+:[^\]]*\]', condition):
+ error(line_number, 'whitespace/colon', 4, 'Missing space around : in range-based for statement')
condition_match = search(r'(?P<leading>[ ]*)(?P<separator>.).*[^ ]+(?P<trailing>[ ]*)', condition)
if condition_match:
n_leading = len(condition_match.group('leading'))
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (252432 => 252433)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2019-11-13 22:47:24 UTC (rev 252432)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2019-11-13 22:56:54 UTC (rev 252433)
@@ -4360,6 +4360,12 @@
'')
self.assert_multi_line_lint(
+ ' for (foo *bar in [foo bar:baz])\n'
+ ' process(bar);\n',
+ '',
+ 'foo.mm')
+
+ self.assert_multi_line_lint(
' for (const Vector& vector: vectors)\n'
' process(vector);\n',
'Missing space around : in range-based for statement [whitespace/colon] [4]')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes