def check_tree(tree):
 assert (tree.tag == 'codeintel'), 'can only check starting from <codeintel> element'
 assert (tree.get('version') == CIX_VERSION), ('can only check CIX v%s trees' % CIX_VERSION)
 file = tree[0]
 if (not file.get('lang')):
  (yield ('error', "no 'lang' attr on <file> element"))
 if file.get('language'):
  (yield ('warning', "'language' attr on <file> element is obsolete,use 'lang'"))
 for blob in file:
  if (blob.get('ilk') != 'blob'):
   (yield ('error', ('element under <file> is not ilk=blob: %r' % blob)))
  if (not blob.get('lang')):
   (yield ('error', ("no 'lang' attr on <blob> element: %r" % blob)))
  for class_elem in blob.getiterator('scope'):
   if (class_elem.get('ilk') != 'class'):
    continue
   classrefs = class_elem.get('classrefs')
   if (not classrefs):
    continue
   if (',' in classrefs):
    (yield ('warning', ("multiple class references in 'classrefs' attr on class scopes must be space-separated: %r may be using comma-separation: %r" % (class_elem, classrefs))))

def check_tree ( tree ) : assert ( tree . tag == 'codeintel' ) , 'can only check starting from <codeintel> element' assert ( tree . get ( 'version' ) == CIX_VERSION ) , ( 'can only check CIX v%s trees' % CIX_VERSION ) file = tree [ 0 ] if ( not file . get ( 'lang' ) ) : ( yield ( 'error' , "no 'lang' attr on <file> element" ) ) if file . get ( 'language' ) : ( yield ( 'warning' , "'language' attr on <file> element is obsolete,use 'lang'" ) ) for blob in file : if ( blob . get ( 'ilk' ) != 'blob' ) : ( yield ( 'error' , ( 'element under <file> is not ilk=blob: %r' % blob ) ) ) if ( not blob . get ( 'lang' ) ) : ( yield ( 'error' , ( "no 'lang' attr on <blob> element: %r" % blob ) ) ) for class_elem in blob . getiterator ( 'scope' ) : if ( class_elem . get ( 'ilk' ) != 'class' ) : continue classrefs = class_elem . get ( 'classrefs' ) if ( not classrefs ) : continue if ( ',' in classrefs ) : ( yield ( 'warning' , ( "multiple class references in 'classrefs' attr on class scopes must be space-separated: %r may be using comma-separation: %r" % ( class_elem , classrefs ) ) ) )
generate warnings/errors for common mistakes in cix trees .