Title: [200059] trunk/Tools
- Revision
- 200059
- Author
- [email protected]
- Date
- 2016-04-25 16:41:51 -0700 (Mon, 25 Apr 2016)
Log Message
[Tools] whitelist all-uppercase JSTokenType enum in _javascript_Core
https://bugs.webkit.org/show_bug.cgi?id=156976
Patch by Caitlin Potter <[email protected]> on 2016-04-25
Reviewed by Darin Adler.
Mitigate style-checker spam on bugs which introduce new _javascript_
token types.
* Scripts/webkitpy/style/checkers/cpp.py:
(_EnumState.__init__):
(_EnumState.process_clean_line):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(NoNonVirtualDestructorsTest.test_enum_casing):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (200058 => 200059)
--- trunk/Tools/ChangeLog 2016-04-25 23:39:01 UTC (rev 200058)
+++ trunk/Tools/ChangeLog 2016-04-25 23:41:51 UTC (rev 200059)
@@ -1,3 +1,19 @@
+2016-04-25 Caitlin Potter <[email protected]>
+
+ [Tools] whitelist all-uppercase JSTokenType enum in _javascript_Core
+ https://bugs.webkit.org/show_bug.cgi?id=156976
+
+ Reviewed by Darin Adler.
+
+ Mitigate style-checker spam on bugs which introduce new _javascript_
+ token types.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (_EnumState.__init__):
+ (_EnumState.process_clean_line):
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (NoNonVirtualDestructorsTest.test_enum_casing):
+
2016-04-25 Simon Fraser <[email protected]>
Fix issues with content-animation performance tests
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (200058 => 200059)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2016-04-25 23:39:01 UTC (rev 200058)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2016-04-25 23:41:51 UTC (rev 200059)
@@ -1240,6 +1240,7 @@
def __init__(self):
self.in_enum_decl = False
self.is_webidl_enum = False
+ self.enum_decl_name = None
def process_clean_line(self, line):
# FIXME: The regular expressions for expr_all_uppercase and expr_enum_end only accept integers
@@ -1248,27 +1249,29 @@
expr_all_uppercase = r'\s*[A-Z0-9_]+\s*(?:=\s*[a-zA-Z0-9]+\s*)?,?\s*$'
expr_starts_lowercase = r'\s*[a-jl-z]'
expr_enum_end = r'}\s*(?:[a-zA-Z0-9]+\s*(?:=\s*[a-zA-Z0-9]+)?)?\s*;\s*'
- expr_enum_start = r'\s*(?:enum(?:\s+class)?(?:\s+[a-zA-Z0-9]+)?)\s*\{?\s*'
+ expr_enum_start = r'\s*(?:enum(?:\s+class)?(?:\s+(?P<identifier>[a-zA-Z0-9]+))?)\s*\{?\s*'
if self.in_enum_decl:
if match(r'\s*' + expr_enum_end + r'$', line):
self.in_enum_decl = False
self.is_webidl_enum = False
return True
elif match(expr_all_uppercase, line):
- return self.is_webidl_enum
+ return self.is_webidl_enum or self.enum_decl_name in _ALLOW_ALL_UPPERCASE_ENUM
elif match(expr_starts_lowercase, line):
return False
matched = match(expr_enum_start + r'$', line)
if matched:
self.in_enum_decl = True
+ self.enum_decl_name = matched.group('identifier')
else:
matched = match(expr_enum_start + r'(?P<members>.*)' + expr_enum_end + r'$', line)
if matched:
members = matched.group('members').split(',')
+ allow_all_uppercase = matched.group('identifier') in _ALLOW_ALL_UPPERCASE_ENUM
found_invalid_member = False
for member in members:
if match(expr_all_uppercase, member):
- found_invalid_member = not self.is_webidl_enum
+ found_invalid_member = not self.is_webidl_enum and not allow_all_uppercase
if match(expr_starts_lowercase, member):
found_invalid_member = True
if found_invalid_member:
@@ -2139,6 +2142,9 @@
break;
+# Enum declaration whitelist
+_ALLOW_ALL_UPPERCASE_ENUM = ['JSTokenType']
+
def check_enum_casing(clean_lines, line_number, enum_state, error):
"""Looks for incorrectly named enum values.
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (200058 => 200059)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2016-04-25 23:39:01 UTC (rev 200058)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2016-04-25 23:41:51 UTC (rev 200059)
@@ -3585,8 +3585,24 @@
};''',
['enum members should use InterCaps with an initial capital letter or initial \'k\' for C-style enums. [readability/enum_casing] [4]'] * 5)
+ # Allow all-caps enum for JSTokenType
self.assert_multi_line_lint(
'''\
+ enum JSTokenType {
+ NULLTOKEN = KeywordTokenFlag,
+ TRUETOKEN,
+ FALSETOKEN,
+ // ...
+ };''',
+ '')
+
+ self.assert_multi_line_lint(
+ '''\
+ enum JSTokenType { NULLTOKEN = KeywordTokenFlag, TRUETOKEN, FALSETOKEN };''',
+ '')
+
+ self.assert_multi_line_lint(
+ '''\
enum Foo {
fooOne = 1,
FooTwo = 2
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes