@@ -111,6 +111,7 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dic
111
111
is_predicate = prop .is_predicate ,
112
112
is_unordered = prop .is_unordered ,
113
113
description = prop .description ,
114
+ synth = bool (cls .synth ) or prop .synth ,
114
115
type_is_hideable = lookup [prop .type ].hideable if prop .type in lookup else False ,
115
116
)
116
117
if prop .is_single :
@@ -163,7 +164,6 @@ def get_ql_class(cls: schema.Class, lookup: typing.Dict[str, schema.Class]) -> q
163
164
final = not cls .derived ,
164
165
properties = properties ,
165
166
dir = pathlib .Path (cls .group or "" ),
166
- ipa = bool (cls .ipa ),
167
167
doc = cls .doc ,
168
168
hideable = cls .hideable ,
169
169
** pragmas ,
@@ -179,26 +179,26 @@ def _to_db_type(x: str) -> str:
179
179
_final_db_class_lookup = {}
180
180
181
181
182
- def get_ql_ipa_class_db (name : str ) -> ql .Synth .FinalClassDb :
182
+ def get_ql_synth_class_db (name : str ) -> ql .Synth .FinalClassDb :
183
183
return _final_db_class_lookup .setdefault (name , ql .Synth .FinalClassDb (name = name ,
184
184
params = [
185
185
ql .Synth .Param ("id" , _to_db_type (name ))]))
186
186
187
187
188
- def get_ql_ipa_class (cls : schema .Class ):
188
+ def get_ql_synth_class (cls : schema .Class ):
189
189
if cls .derived :
190
190
return ql .Synth .NonFinalClass (name = cls .name , derived = sorted (cls .derived ),
191
191
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 )
202
202
203
203
204
204
def 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
291
291
292
292
293
293
def _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 :
296
296
accessors = [
297
- ql .IpaUnderlyingAccessor (
297
+ ql .SynthUnderlyingAccessor (
298
298
argument = "Entity" ,
299
- type = _to_db_type (cls .ipa .from_class ),
299
+ type = _to_db_type (cls .synth .from_class ),
300
300
constructorparams = ["result" ]
301
301
)
302
302
]
303
- elif cls .ipa .on_arguments is not None :
303
+ elif cls .synth .on_arguments is not None :
304
304
accessors = [
305
- ql .IpaUnderlyingAccessor (
305
+ ql .SynthUnderlyingAccessor (
306
306
argument = inflection .camelize (arg ),
307
307
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 ()
310
310
]
311
311
else :
312
312
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 )
314
314
315
315
316
316
def generate (opts , renderer ):
@@ -344,7 +344,7 @@ def generate(opts, renderer):
344
344
with renderer .manage (generated = generated , stubs = stubs , registry = opts .generated_registry ,
345
345
force = opts .force ) as renderer :
346
346
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 ]
348
348
renderer .render (ql .DbClasses (db_classes ), out / "Raw.qll" )
349
349
350
350
classes_by_dir_and_name = sorted (classes .values (), key = lambda cls : (cls .dir , cls .name ))
@@ -401,32 +401,32 @@ def generate(opts, renderer):
401
401
elements_module = elements_module ,
402
402
property = p ), test_dir / f"{ c .name } _{ p .getter } .ql" )
403
403
404
- final_ipa_types = []
405
- non_final_ipa_types = []
404
+ final_synth_types = []
405
+ non_final_synth_types = []
406
406
constructor_imports = []
407
- ipa_constructor_imports = []
407
+ synth_constructor_imports = []
408
408
stubs = {}
409
409
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 :
414
414
stub_file = stub_out / cls .group / f"{ cls .name } Constructor.qll"
415
415
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 )
418
418
constructor_import = get_import (stub_file , opts .root_dir )
419
419
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 )
422
422
else :
423
- non_final_ipa_types .append (ipa_type )
423
+ non_final_synth_types .append (synth_type )
424
424
425
425
for stub_file , data in stubs .items ():
426
426
renderer .render (data , stub_file )
427
427
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" )
429
429
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" )
431
431
if opts .ql_format :
432
432
format (opts .codeql_binary , renderer .written )
0 commit comments