@@ -111,6 +111,7 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dic
111111 is_predicate = prop .is_predicate ,
112112 is_unordered = prop .is_unordered ,
113113 description = prop .description ,
114+ synth = bool (cls .synth ) or prop .synth ,
114115 type_is_hideable = lookup [prop .type ].hideable if prop .type in lookup else False ,
115116 )
116117 if prop .is_single :
@@ -163,7 +164,6 @@ def get_ql_class(cls: schema.Class, lookup: typing.Dict[str, schema.Class]) -> q
163164 final = not cls .derived ,
164165 properties = properties ,
165166 dir = pathlib .Path (cls .group or "" ),
166- ipa = bool (cls .ipa ),
167167 doc = cls .doc ,
168168 hideable = cls .hideable ,
169169 ** pragmas ,
@@ -179,26 +179,26 @@ def _to_db_type(x: str) -> str:
179179_final_db_class_lookup = {}
180180
181181
182- def get_ql_ipa_class_db (name : str ) -> ql .Synth .FinalClassDb :
182+ def get_ql_synth_class_db (name : str ) -> ql .Synth .FinalClassDb :
183183 return _final_db_class_lookup .setdefault (name , ql .Synth .FinalClassDb (name = name ,
184184 params = [
185185 ql .Synth .Param ("id" , _to_db_type (name ))]))
186186
187187
188- def get_ql_ipa_class (cls : schema .Class ):
188+ def get_ql_synth_class (cls : schema .Class ):
189189 if cls .derived :
190190 return ql .Synth .NonFinalClass (name = cls .name , derived = sorted (cls .derived ),
191191 root = not cls .bases )
192- if cls .ipa and cls .ipa .from_class is not None :
193- source = cls .ipa .from_class
194- get_ql_ipa_class_db (source ).subtract_type (cls .name )
195- return ql .Synth .FinalClassDerivedIpa (name = cls .name ,
196- params = [ql .Synth .Param ("id" , _to_db_type (source ))])
197- if cls .ipa and cls .ipa .on_arguments is not None :
198- return ql .Synth .FinalClassFreshIpa (name = cls .name ,
199- params = [ql .Synth .Param (k , _to_db_type (v ))
200- for k , v in cls .ipa .on_arguments .items ()])
201- return get_ql_ipa_class_db (cls .name )
192+ if cls .synth and cls .synth .from_class is not None :
193+ source = cls .synth .from_class
194+ get_ql_synth_class_db (source ).subtract_type (cls .name )
195+ return ql .Synth .FinalClassDerivedSynth (name = cls .name ,
196+ params = [ql .Synth .Param ("id" , _to_db_type (source ))])
197+ if cls .synth and cls .synth .on_arguments is not None :
198+ return ql .Synth .FinalClassFreshSynth (name = cls .name ,
199+ params = [ql .Synth .Param (k , _to_db_type (v ))
200+ for k , v in cls .synth .on_arguments .items ()])
201+ return get_ql_synth_class_db (cls .name )
202202
203203
204204def get_import (file : pathlib .Path , root_dir : pathlib .Path ):
@@ -291,26 +291,26 @@ def _should_skip_qltest(cls: schema.Class, lookup: typing.Dict[str, schema.Class
291291
292292
293293def _get_stub (cls : schema .Class , base_import : str , generated_import_prefix : str ) -> ql .Stub :
294- if isinstance (cls .ipa , schema .IpaInfo ):
295- if cls .ipa .from_class is not None :
294+ if isinstance (cls .synth , schema .SynthInfo ):
295+ if cls .synth .from_class is not None :
296296 accessors = [
297- ql .IpaUnderlyingAccessor (
297+ ql .SynthUnderlyingAccessor (
298298 argument = "Entity" ,
299- type = _to_db_type (cls .ipa .from_class ),
299+ type = _to_db_type (cls .synth .from_class ),
300300 constructorparams = ["result" ]
301301 )
302302 ]
303- elif cls .ipa .on_arguments is not None :
303+ elif cls .synth .on_arguments is not None :
304304 accessors = [
305- ql .IpaUnderlyingAccessor (
305+ ql .SynthUnderlyingAccessor (
306306 argument = inflection .camelize (arg ),
307307 type = _to_db_type (type ),
308- constructorparams = ["result" if a == arg else "_" for a in cls .ipa .on_arguments ]
309- ) for arg , type in cls .ipa .on_arguments .items ()
308+ constructorparams = ["result" if a == arg else "_" for a in cls .synth .on_arguments ]
309+ ) for arg , type in cls .synth .on_arguments .items ()
310310 ]
311311 else :
312312 accessors = []
313- return ql .Stub (name = cls .name , base_import = base_import , import_prefix = generated_import_prefix , ipa_accessors = accessors )
313+ return ql .Stub (name = cls .name , base_import = base_import , import_prefix = generated_import_prefix , synth_accessors = accessors )
314314
315315
316316def generate (opts , renderer ):
@@ -344,7 +344,7 @@ def generate(opts, renderer):
344344 with renderer .manage (generated = generated , stubs = stubs , registry = opts .generated_registry ,
345345 force = opts .force ) as renderer :
346346
347- db_classes = [cls for cls in classes .values () if not cls . ipa ]
347+ db_classes = [cls for name , cls in classes .items () if not data . classes [ name ]. synth ]
348348 renderer .render (ql .DbClasses (db_classes ), out / "Raw.qll" )
349349
350350 classes_by_dir_and_name = sorted (classes .values (), key = lambda cls : (cls .dir , cls .name ))
@@ -401,32 +401,32 @@ def generate(opts, renderer):
401401 elements_module = elements_module ,
402402 property = p ), test_dir / f"{ c .name } _{ p .getter } .ql" )
403403
404- final_ipa_types = []
405- non_final_ipa_types = []
404+ final_synth_types = []
405+ non_final_synth_types = []
406406 constructor_imports = []
407- ipa_constructor_imports = []
407+ synth_constructor_imports = []
408408 stubs = {}
409409 for cls in sorted (data .classes .values (), key = lambda cls : (cls .group , cls .name )):
410- ipa_type = get_ql_ipa_class (cls )
411- if ipa_type .is_final :
412- final_ipa_types .append (ipa_type )
413- if ipa_type .has_params :
410+ synth_type = get_ql_synth_class (cls )
411+ if synth_type .is_final :
412+ final_synth_types .append (synth_type )
413+ if synth_type .has_params :
414414 stub_file = stub_out / cls .group / f"{ cls .name } Constructor.qll"
415415 if not renderer .is_customized_stub (stub_file ):
416- # stub rendering must be postponed as we might not have yet all subtracted ipa types in `ipa_type `
417- stubs [stub_file ] = ql .Synth .ConstructorStub (ipa_type , import_prefix = generated_import_prefix )
416+ # stub rendering must be postponed as we might not have yet all subtracted synth types in `synth_type `
417+ stubs [stub_file ] = ql .Synth .ConstructorStub (synth_type , import_prefix = generated_import_prefix )
418418 constructor_import = get_import (stub_file , opts .root_dir )
419419 constructor_imports .append (constructor_import )
420- if ipa_type . is_ipa :
421- ipa_constructor_imports .append (constructor_import )
420+ if synth_type . is_synth :
421+ synth_constructor_imports .append (constructor_import )
422422 else :
423- non_final_ipa_types .append (ipa_type )
423+ non_final_synth_types .append (synth_type )
424424
425425 for stub_file , data in stubs .items ():
426426 renderer .render (data , stub_file )
427427 renderer .render (ql .Synth .Types (root .name , generated_import_prefix ,
428- final_ipa_types , non_final_ipa_types ), out / "Synth.qll" )
428+ final_synth_types , non_final_synth_types ), out / "Synth.qll" )
429429 renderer .render (ql .ImportList (constructor_imports ), out / "SynthConstructors.qll" )
430- renderer .render (ql .ImportList (ipa_constructor_imports ), out / "PureSynthConstructors.qll" )
430+ renderer .render (ql .ImportList (synth_constructor_imports ), out / "PureSynthConstructors.qll" )
431431 if opts .ql_format :
432432 format (opts .codeql_binary , renderer .written )
0 commit comments