<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180981] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180981">180981</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-03-03 18:47:53 -0800 (Tue, 03 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>check-webkit-style: Add exception for FrameworkSoftLink.h header order
&lt;http://webkit.org/b/141872&gt;

Reviewed by Alex Christensen.

* Scripts/webkitpy/style/checkers/cpp.py: Remove unneeded
semi-colons in various places and fix whitespace.
(_IncludeState): Add _SOFT_LINK_HEADER and _SOFT_LINK_SECTION
constants.
(_IncludeState.__init__): Add self._visited_soft_link_section
boolean state variable.
(_IncludeState.visited_soft_link_section): Getter for
self._visited_soft_link_section.
(_IncludeState.check_next_include_order): Update state machine
for soft-link headers.  Add check that soft-link headers always
appear last.
(_classify_include): Add check for soft-link header type.
(check_include_line): Return early if there is a soft-link
header error.

* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(OrderOfIncludesTest.test_public_primary_header): Add tests for
including soft-link headers.
(OrderOfIncludesTest.test_classify_include): Add test for
_SOFT_LINK_HEADER type.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerscpppy">trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerscpp_unittestpy">trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (180980 => 180981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-04 02:37:58 UTC (rev 180980)
+++ trunk/Tools/ChangeLog        2015-03-04 02:47:53 UTC (rev 180981)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-03-03  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
+        check-webkit-style: Add exception for FrameworkSoftLink.h header order
+        &lt;http://webkit.org/b/141872&gt;
+
+        Reviewed by Alex Christensen.
+
+        * Scripts/webkitpy/style/checkers/cpp.py: Remove unneeded
+        semi-colons in various places and fix whitespace.
+        (_IncludeState): Add _SOFT_LINK_HEADER and _SOFT_LINK_SECTION
+        constants.
+        (_IncludeState.__init__): Add self._visited_soft_link_section
+        boolean state variable.
+        (_IncludeState.visited_soft_link_section): Getter for
+        self._visited_soft_link_section.
+        (_IncludeState.check_next_include_order): Update state machine
+        for soft-link headers.  Add check that soft-link headers always
+        appear last.
+        (_classify_include): Add check for soft-link header type.
+        (check_include_line): Return early if there is a soft-link
+        header error.
+
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (OrderOfIncludesTest.test_public_primary_header): Add tests for
+        including soft-link headers.
+        (OrderOfIncludesTest.test_classify_include): Add test for
+        _SOFT_LINK_HEADER type.
+
</ins><span class="cx"> 2015-03-03  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         build.webkit.org/dashboard: Don't repeatedly handle each test type
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerscpppy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (180980 => 180981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py        2015-03-04 02:37:58 UTC (rev 180980)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py        2015-03-04 02:47:53 UTC (rev 180981)
</span><span class="lines">@@ -118,7 +118,8 @@
</span><span class="cx"> _CONFIG_HEADER = 0
</span><span class="cx"> _PRIMARY_HEADER = 1
</span><span class="cx"> _OTHER_HEADER = 2
</span><del>-_MOC_HEADER = 3
</del><ins>+_SOFT_LINK_HEADER = 3
+_MOC_HEADER = 4
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> # A dictionary of items customize behavior for unit test. For example,
</span><span class="lines">@@ -254,11 +255,13 @@
</span><span class="cx">     _CONFIG_SECTION = 1
</span><span class="cx">     _PRIMARY_SECTION = 2
</span><span class="cx">     _OTHER_SECTION = 3
</span><ins>+    _SOFT_LINK_SECTION = 4
</ins><span class="cx"> 
</span><span class="cx">     _TYPE_NAMES = {
</span><span class="cx">         _CONFIG_HEADER: 'WebCore config.h',
</span><span class="cx">         _PRIMARY_HEADER: 'header this file implements',
</span><span class="cx">         _OTHER_HEADER: 'other header',
</span><ins>+        _SOFT_LINK_HEADER: '*SoftLink.h header',
</ins><span class="cx">         _MOC_HEADER: 'moc file',
</span><span class="cx">         }
</span><span class="cx">     _SECTION_NAMES = {
</span><span class="lines">@@ -266,17 +269,22 @@
</span><span class="cx">         _CONFIG_SECTION: &quot;WebCore config.h.&quot;,
</span><span class="cx">         _PRIMARY_SECTION: 'a header this file implements.',
</span><span class="cx">         _OTHER_SECTION: 'other header.',
</span><ins>+        _SOFT_LINK_SECTION: 'soft-link header section.',
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">     def __init__(self):
</span><span class="cx">         dict.__init__(self)
</span><span class="cx">         self._section = self._INITIAL_SECTION
</span><span class="cx">         self._visited_primary_section = False
</span><del>-        self.header_types = dict();
</del><ins>+        self._visited_soft_link_section = False
+        self.header_types = dict()
</ins><span class="cx"> 
</span><span class="cx">     def visited_primary_section(self):
</span><span class="cx">         return self._visited_primary_section
</span><span class="cx"> 
</span><ins>+    def visited_soft_link_section(self):
+        return self._visited_soft_link_section
+
</ins><span class="cx">     def check_next_include_order(self, header_type, filename, file_is_header, primary_header_exists):
</span><span class="cx">         &quot;&quot;&quot;Returns a non-empty error message if the next header is out of order.
</span><span class="cx"> 
</span><span class="lines">@@ -302,7 +310,7 @@
</span><span class="cx">             return ''
</span><span class="cx"> 
</span><span class="cx">         error_message = ''
</span><del>-        if self._section != self._OTHER_SECTION:
</del><ins>+        if self._section &lt; self._OTHER_SECTION:
</ins><span class="cx">             before_error_message = ('Found %s before %s' %
</span><span class="cx">                                     (self._TYPE_NAMES[header_type],
</span><span class="cx">                                      self._SECTION_NAMES[self._section + 1]))
</span><span class="lines">@@ -321,13 +329,22 @@
</span><span class="cx">                 error_message = before_error_message
</span><span class="cx">             self._section = self._PRIMARY_SECTION
</span><span class="cx">             self._visited_primary_section = True
</span><del>-        else:
-            assert header_type == _OTHER_HEADER
</del><ins>+        elif header_type == _OTHER_HEADER:
</ins><span class="cx">             if not file_is_header and self._section &lt; self._PRIMARY_SECTION:
</span><span class="cx">                 if primary_header_exists and not filename.endswith('SoftLink.cpp'):
</span><span class="cx">                     error_message = before_error_message
</span><span class="cx">             self._section = self._OTHER_SECTION
</span><ins>+        else:
+            assert header_type == _SOFT_LINK_HEADER
+            if file_is_header:
+                error_message = '{} should never be included in a header.'.format(
+                    self._TYPE_NAMES[header_type])
+            self._section = self._SOFT_LINK_SECTION
+            self._visited_soft_link_section = True
</ins><span class="cx"> 
</span><ins>+        if not error_message and self.visited_soft_link_section() and header_type != _SOFT_LINK_HEADER:
+            error_message = '*SoftLink.h header should be included after all other headers.'
+
</ins><span class="cx">         return error_message
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2880,11 +2897,15 @@
</span><span class="cx">     if include == &quot;config.h&quot;:
</span><span class="cx">         return _CONFIG_HEADER
</span><span class="cx"> 
</span><ins>+    # If the include is named *SoftLink.h, then it's a soft-link header.
+    if include.endswith('SoftLink.h'):
+        return _SOFT_LINK_HEADER
+
</ins><span class="cx">     # There cannot be primary includes in header files themselves. Only an
</span><span class="cx">     # include exactly matches the header filename will be is flagged as
</span><span class="cx">     # primary, so that it triggers the &quot;don't include yourself&quot; check.
</span><span class="cx">     if filename.endswith('.h') and filename != include:
</span><del>-        return _OTHER_HEADER;
</del><ins>+        return _OTHER_HEADER
</ins><span class="cx"> 
</span><span class="cx">     # If the target file basename starts with the include we're checking
</span><span class="cx">     # then we consider it the primary header.
</span><span class="lines">@@ -2987,6 +3008,11 @@
</span><span class="cx">                                                            file_extension == &quot;h&quot;,
</span><span class="cx">                                                            primary_header_exists)
</span><span class="cx"> 
</span><ins>+    # Check to make sure *SoftLink.h headers always appear last and never in a header.
+    if error_message and include_state.visited_soft_link_section():
+        error(line_number, 'build/include_order', 4, error_message)
+        return
+
</ins><span class="cx">     # Check to make sure we have a blank line after and none before primary header.
</span><span class="cx">     if not error_message and header_type == _PRIMARY_HEADER:
</span><span class="cx">         next_line = clean_lines.raw_lines[line_number + 1]
</span><span class="lines">@@ -3001,15 +3027,15 @@
</span><span class="cx">     # Check to make sure all headers besides config.h and the primary header are
</span><span class="cx">     # alphabetically sorted.
</span><span class="cx">     if not error_message and header_type == _OTHER_HEADER:
</span><del>-         previous_line_number = line_number - 1;
-         previous_line = clean_lines.lines[previous_line_number]
-         previous_match = _RE_PATTERN_INCLUDE.search(previous_line)
-         while (not previous_match and previous_line_number &gt; 0
-                and not search(r'\A(#if|#ifdef|#ifndef|#else|#elif|#endif)', previous_line)):
-            previous_line_number -= 1;
</del><ins>+        previous_line_number = line_number - 1
+        previous_line = clean_lines.lines[previous_line_number]
+        previous_match = _RE_PATTERN_INCLUDE.search(previous_line)
+        while (not previous_match and previous_line_number &gt; 0
+               and not search(r'\A(#if|#ifdef|#ifndef|#else|#elif|#endif)', previous_line)):
+            previous_line_number -= 1
</ins><span class="cx">             previous_line = clean_lines.lines[previous_line_number]
</span><span class="cx">             previous_match = _RE_PATTERN_INCLUDE.search(previous_line)
</span><del>-         if previous_match:
</del><ins>+        if previous_match:
</ins><span class="cx">             previous_header_type = include_state.header_types[previous_line_number]
</span><span class="cx">             if previous_header_type == _OTHER_HEADER:
</span><span class="cx">                 if '&lt;' in previous_line and '&quot;' in line:
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerscpp_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (180980 => 180981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py        2015-03-04 02:37:58 UTC (rev 180980)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py        2015-03-04 02:47:53 UTC (rev 180981)
</span><span class="lines">@@ -2859,6 +2859,74 @@
</span><span class="cx">                                          '#include &quot;a.h&quot;\n',
</span><span class="cx">                                          'Bad include order. Mixing system and custom headers.  [build/include_order] [4]')
</span><span class="cx"> 
</span><ins>+        # *SoftLink.h header should never be included in other header files.
+        self.assert_language_rules_check('foo.h',
+                                         '#include &quot;Bar.h&quot;\n'
+                                         '\n'
+                                         '#include &quot;FrameworkSoftLink.h&quot;\n',
+                                         '*SoftLink.h header should never be included in a header.  [build/include_order] [4]')
+
+        # Complain about *SoftLink.h headers that are not last.
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include &quot;config.h&quot;\n'
+                                         '#include &quot;Foo.h&quot;\n'
+                                         '\n'
+                                         '#include &quot;ALocalHeader.h&quot;\n'
+                                         '#include &quot;FrameworkSoftLink.h&quot;\n'
+                                         '#include &lt;Framework/Bar.h&gt;\n',
+                                         '*SoftLink.h header should be included after all other headers.  [build/include_order] [4]')
+
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include &quot;config.h&quot;\n'
+                                         '#include &quot;Foo.h&quot;\n'
+                                         '\n'
+                                         '#include &quot;ALocalHeader.h&quot;\n'
+                                         '#include &lt;Framework/Bar.h&gt;\n'
+                                         '\n'
+                                         '#include &quot;FrameworkSoftLink.h&quot;\n'
+                                         '\n'
+                                         '#if PLATFORM(FOO)\n'
+                                         '#include &quot;FooPlatform.h&quot;\n'
+                                         '#endif // PLATFORM(FOO)\n',
+                                         '*SoftLink.h header should be included after all other headers.  [build/include_order] [4]')
+
+        # Don't complain about *SoftLink.h headers that are last.
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include &quot;config.h&quot;\n'
+                                         '#include &quot;Foo.h&quot;\n'
+                                         '\n'
+                                         '#include &quot;ALocalHeader.h&quot;\n'
+                                         '#include &lt;Framework/Bar.h&gt;\n'
+                                         '\n'
+                                         '#if PLATFORM(FOO)\n'
+                                         '#include &quot;FooPlatform.h&quot;\n'
+                                         '#endif // PLATFORM(FOO)\n'
+                                         '\n'
+                                         '#include &quot;FrameworkSoftLink.h&quot;\n',
+                                         '')
+
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include &quot;config.h&quot;\n'
+                                         '#include &quot;Foo.h&quot;\n'
+                                         '\n'
+                                         '#include &quot;ALocalHeader.h&quot;\n'
+                                         '#include &lt;Framework/Bar.h&gt;\n'
+                                         '\n'
+                                         '#if PLATFORM(FOO)\n'
+                                         '#include &quot;FooPlatform.h&quot;\n'
+                                         '#endif // PLATFORM(FOO)\n'
+                                         '\n'
+                                         '#include &quot;FrameworkASoftLink.h&quot;\n'
+                                         '#include &quot;FrameworkBSoftLink.h&quot;\n',
+                                         '')
+
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include &quot;config.h&quot;\n'
+                                         '#include &lt;Framework/Bar.h&gt;\n'
+                                         '\n'
+                                         '#include &quot;FrameworkSoftLink.h&quot;\n',
+                                         '')
+
</ins><span class="cx">     def test_check_wtf_includes(self):
</span><span class="cx">         self.assert_language_rules_check('foo.cpp',
</span><span class="cx">                                          '#include &quot;config.h&quot;\n'
</span><span class="lines">@@ -2918,6 +2986,10 @@
</span><span class="cx">                          classify_include('foo.cpp',
</span><span class="cx">                                           'public/foop.h',
</span><span class="cx">                                           True, include_state))
</span><ins>+        self.assertEqual(cpp_style._SOFT_LINK_HEADER,
+                         classify_include('foo.cpp',
+                                          'BarSoftLink.h',
+                                          False, include_state))
</ins><span class="cx">         # Tricky example where both includes might be classified as primary.
</span><span class="cx">         self.assert_language_rules_check('ScrollbarThemeWince.cpp',
</span><span class="cx">                                          '#include &quot;config.h&quot;\n'
</span></span></pre>
</div>
</div>

</body>
</html>