[gobject-introspection] giscanner: only warn about missing delimiter when necessary



commit 4c23f8ba830cf136916e95d18b5aacdb03bc64b7
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Wed May 29 14:05:24 2013 +0200

    giscanner: only warn about missing delimiter when necessary
    
    Turns out gtkdoc-mkdb has always accepted identifier parts
    with and without a delimiter after the identifier_name field,
    so it is safe to only require it when annotations are present or
    in other words, when there are actually multiple fields to be
    seperated...

 giscanner/annotationparser.py                      |   18 +++++++++---------
 .../annotationparser/gi/identifier_symbol.xml      |   15 ---------------
 tests/scanner/annotationparser/gi/syntax.xml       |    6 ------
 3 files changed, 9 insertions(+), 30 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d5da84c..fb11a67 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -1010,18 +1010,18 @@ class GtkDocCommentBlockParser(object):
                     comment_block = DocBlock(identifier_name)
                     comment_block.position = position
 
-                    if 'delimiter' in result.groupdict() and result.group('delimiter') != ':':
-                        delimiter_start = result.start('delimiter')
-                        delimiter_column = column_offset + delimiter_start
-                        marker = ' ' * delimiter_column + '^'
-                        message.warn("missing ':' at column %s:\n%s\n%s" %
-                                     (delimiter_column + 1, original_line, marker),
-                                     position)
-
-                    if 'annotations' in result.groupdict():
+                    if 'annotations' in result.groupdict() and result.group('annotations') != '':
                         comment_block.annotations = self.parse_annotations(comment_block,
                                                                        result.group('annotations'))
 
+                        if 'delimiter' in result.groupdict() and result.group('delimiter') != ':':
+                            delimiter_start = result.start('delimiter')
+                            delimiter_column = column_offset + delimiter_start
+                            marker = ' ' * delimiter_column + '^'
+                            message.warn("missing ':' at column %s:\n%s\n%s" %
+                                         (delimiter_column + 1, original_line, marker),
+                                         position)
+
                     continue
                 else:
                     # If we get here, the identifier was not recognized, so
diff --git a/tests/scanner/annotationparser/gi/identifier_symbol.xml 
b/tests/scanner/annotationparser/gi/identifier_symbol.xml
index 179b315..7e31776 100644
--- a/tests/scanner/annotationparser/gi/identifier_symbol.xml
+++ b/tests/scanner/annotationparser/gi/identifier_symbol.xml
@@ -15,11 +15,6 @@
       </identifier>
       <description>test_symbol does something nifty.</description>
     </docblock>
-    <messages>
-      <message>2: Warning: Test: missing ':' at column 15:
- * test_symbol
-              ^</message>
-    </messages>
   </parser>
 </test>
 
@@ -99,11 +94,6 @@
       </identifier>
       <description>Some property.</description>
     </docblock>
-    <messages>
-      <message>2: Warning: Test: missing ':' at column 27:
- * GtkWidget:test_property
-                          ^</message>
-    </messages>
   </parser>
 </test>
 
@@ -183,11 +173,6 @@
       </identifier>
       <description>Some signal.</description>
     </docblock>
-    <messages>
-      <message>2: Warning: Test: missing ':' at column 26:
- * GtkWidget::test_signal
-                         ^</message>
-    </messages>
   </parser>
 </test>
 
diff --git a/tests/scanner/annotationparser/gi/syntax.xml b/tests/scanner/annotationparser/gi/syntax.xml
index de8f04f..32528fb 100644
--- a/tests/scanner/annotationparser/gi/syntax.xml
+++ b/tests/scanner/annotationparser/gi/syntax.xml
@@ -96,9 +96,6 @@ something */</input>
       <message>3: Warning: Test: Comments should end with */ on a new line:
 something */
          ^</message>
-      <message>2: Warning: Test: missing ':' at column 5:
-Test
-    ^</message>
     </messages>
   </parser>
 </test>
@@ -122,9 +119,6 @@ something **/</input>
       <message>3: Warning: Test: Comments should end with */ on a new line:
 something **/
          ^</message>
-      <message>2: Warning: Test: missing ':' at column 5:
-Test
-    ^</message>
     </messages>
   </parser>
 </test>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]