@@ -128,15 +128,18 @@ def annotate_as_appropriate(filename, lines):
128128 return insert_toplevel_maybe_local_annotation (filename , lines )
129129
130130
131- def process_single_file (filename ):
131+ def process_single_file (check , filename ):
132132 '''
133133 Process a single file, annotating it as appropriate and writing the changes back to the file.
134134 '''
135135 old = [line for line in open (filename )]
136136
137137 annotate_result = annotate_as_appropriate (filename , old )
138138 if annotate_result is None :
139- return
139+ return False
140+
141+ if check :
142+ return True
140143
141144 new = annotate_result [1 ]
142145
@@ -151,8 +154,15 @@ def process_single_file(filename):
151154 out_file .write (line )
152155
153156
157+ if len (sys .argv ) > 1 and sys .argv [1 ] == "--check" :
158+ check = True
159+ langs = sys .argv [2 :]
160+ else :
161+ check = False
162+ langs = sys .argv [1 :]
163+
154164dirs = []
155- for lang in sys . argv [ 1 :] :
165+ for lang in langs :
156166 if lang in ["cpp" , "go" , "csharp" , "java" , "javascript" , "python" , "ruby" , "rust" , "swift" ]:
157167 dirs .append (f"{ lang } /ql/lib" )
158168 else :
@@ -161,8 +171,24 @@ def process_single_file(filename):
161171if dirs :
162172 dirs .append ("shared" )
163173
174+ missingAnnotations = []
175+
164176for roots in dirs :
165177 for dirpath , dirnames , filenames in os .walk (roots ):
166178 for filename in filenames :
167179 if filename .endswith (".qll" ) and not dirpath .endswith ("tutorial" ):
168- process_single_file (os .path .join (dirpath , filename ))
180+ path = os .path .join (dirpath , filename )
181+ res = process_single_file (check , path )
182+ if check and res :
183+ missingAnnotations .append (path )
184+
185+
186+ if len (missingAnnotations ) > 0 :
187+ print ("The following files have no overlay annotations:" )
188+ for path in missingAnnotations [:10 ]:
189+ print ("- " + path )
190+ if len (missingAnnotations ) > 10 :
191+ print ("and " + str (len (missingAnnotations ) - 10 ) + " additional files." )
192+ print ()
193+ print ("Please manually add overlay annotations or use the config/add-overlay-annotations.py script to automatically add sensible default overlay annotations." )
194+ exit (- 1 )
0 commit comments