X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=giscanner%2Fannotationparser.py;h=f3bf71ec5770f6a77ddb05926f1e8bf6551c344f;hb=c9516551d29432270f5f840ef315ce34f654a62f;hp=97704801383e5e2c7f43a489fae25a5ec514df05;hpb=a867ab49295f5f6f1f72042c237625905e43953f;p=platform%2Fupstream%2Fgobject-introspection.git diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 9770480..f3bf71e 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -154,10 +154,6 @@ class DocBlock(object): def __repr__(self): return '' % (self.name, self.options) - def set_position(self, position): - self.position = position - self.options.position = position - def get_tag(self, name): return self.tags.get(name) @@ -309,10 +305,6 @@ class DocTag(object): value_str), self.position) return - def set_position(self, position): - self.position = position - self.options.position = position - def _get_gtk_doc_value(self): def serialize_one(option, value, fmt, fmt2): if value: @@ -398,6 +390,7 @@ class DocTag(object): class DocOptions(object): def __init__(self): self.values = [] + self.position = None def __repr__(self): return '' % (self.values, ) @@ -437,7 +430,7 @@ class DocOption(object): def __init__(self, tag, option): self.tag = tag self._array = [] - self._dict = {} + self._dict = odict() # (annotation option1=value1 option2=value2) etc for p in option.split(' '): if '=' in p: @@ -582,14 +575,14 @@ class AnnotationParser(object): comment_lines = list(enumerate(comment.split('\n'))) # Check for the start the comment block. - if COMMENT_START_RE.search(comment_lines[0][1]): + if COMMENT_START_RE.match(comment_lines[0][1]): del comment_lines[0] else: # Not a GTK-Doc comment block. return None # Check for the end the comment block. - if COMMENT_END_RE.search(comment_lines[-1][1]): + if COMMENT_END_RE.match(comment_lines[-1][1]): del comment_lines[-1] # If we get this far, we are inside a GTK-Doc comment block. @@ -644,43 +637,32 @@ class AnnotationParser(object): # Check for GTK-Doc comment block identifier. #################################################################### if not comment_block: - # The correct identifier name would have the colon at the end - # but maintransformer.py does not expect us to do that. So - # make sure to compute an identifier_name without the colon and - # a real_identifier_name with the colon. - if not identifier: - result = SECTION_RE.search(line) + result = SECTION_RE.match(line) if result: identifier = IDENTIFIER_SECTION - real_identifier_name = 'SECTION:%s' % (result.group('section_name')) - identifier_name = real_identifier_name + identifier_name = 'SECTION:%s' % (result.group('section_name')) column = result.start('section_name') + column_offset if not identifier: - result = SYMBOL_RE.search(line) + result = SYMBOL_RE.match(line) if result: identifier = IDENTIFIER_SYMBOL - real_identifier_name = '%s:' % (result.group('symbol_name')) identifier_name = '%s' % (result.group('symbol_name')) column = result.start('symbol_name') + column_offset if not identifier: - result = PROPERTY_RE.search(line) + result = PROPERTY_RE.match(line) if result: identifier = IDENTIFIER_PROPERTY - real_identifier_name = '%s:%s:' % (result.group('class_name'), - result.group('property_name')) identifier_name = '%s:%s' % (result.group('class_name'), result.group('property_name')) column = result.start('property_name') + column_offset if not identifier: - result = SIGNAL_RE.search(line) + result = SIGNAL_RE.match(line) if result: identifier = IDENTIFIER_SIGNAL - real_identifier_name = '%s::%s:' % (result.group('class_name'), - result.group('signal_name')) identifier_name = '%s::%s' % (result.group('class_name'), result.group('signal_name')) column = result.start('signal_name') + column_offset @@ -689,7 +671,7 @@ class AnnotationParser(object): in_part = PART_IDENTIFIER comment_block = DocBlock(identifier_name) - comment_block.set_position(position) + comment_block.position = position if 'colon' in result.groupdict() and result.group('colon') != ':': colon_start = result.start('colon') @@ -724,7 +706,7 @@ class AnnotationParser(object): #################################################################### # Check for comment block parameters. #################################################################### - result = PARAMETER_RE.search(line) + result = PARAMETER_RE.match(line) if result: param_name = result.group('parameter_name') param_annotations = result.group('annotations') @@ -759,7 +741,7 @@ class AnnotationParser(object): position) tag = DocTag(comment_block, param_name) - tag.set_position(position) + tag.position = position tag.comment = param_description if param_annotations: tag.options = self.parse_options(tag, param_annotations) @@ -777,7 +759,7 @@ class AnnotationParser(object): # identifier (when there are no parameters) and encounter an empty # line, we must be parsing the comment block description. #################################################################### - if (EMPTY_LINE_RE.search(line) + if (EMPTY_LINE_RE.match(line) and in_part in [PART_IDENTIFIER, PART_PARAMETERS]): in_part = PART_DESCRIPTION continue @@ -785,7 +767,7 @@ class AnnotationParser(object): #################################################################### # Check for GTK-Doc comment block tags. #################################################################### - result = TAG_RE.search(line) + result = TAG_RE.match(line) if result: tag_name = result.group('tag_name') tag_annotations = result.group('annotations') @@ -879,10 +861,10 @@ class AnnotationParser(object): else: comment_block.comment = '' - for tag in comment_block.tags.itervalues(): + for tag in comment_block.tags.values(): self._clean_comment_block_part(tag) - for param in comment_block.params.itervalues(): + for param in comment_block.params.values(): self._clean_comment_block_part(param) # Validate and store block. @@ -912,9 +894,8 @@ class AnnotationParser(object): :param position: position of `line` in the source file ''' - result = MULTILINE_ANNOTATION_CONTINUATION_RE.search(line) + result = MULTILINE_ANNOTATION_CONTINUATION_RE.match(line) if result: - line = result.group('description') column = result.start('annotations') + column_offset marker = ' '*column + '^' message.warn('ignoring invalid multiline annotation continuation:\n'