Beispiel #1
0
 def file_level_annotations(self):
   """Obtain inferred file level annotations."""
   if self._file_level_annotations:
     return self._file_level_annotations
   self._file_level_annotations = dict(
       sum([list(annotations.ExtractAnnotations(c).items()) for c in self.file_level_comments],
           []))
   return self._file_level_annotations
Beispiel #2
0
  def LeadingCommentPathLookup(self, path):
    """Lookup leading comment by path in SourceCodeInfo.

    Args:
      path: a list of path indexes as per
        https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717.

    Returns:
      Comment object.
    """
    location = self.LocationPathLookup(path)
    if location is not None:
      return Comment(
          location.leading_comments,
          annotations.ExtractAnnotations(location.leading_comments, self.file_level_annotations))
    return Comment('', {})
Beispiel #3
0
 def __init__(self, comment, file_level_annotations=None):
     self.raw = comment
     self.file_level_annotations = file_level_annotations
     self.annotations = annotations.ExtractAnnotations(
         self.raw, file_level_annotations)