C#: Add partial model printer for TargetApi class.

This commit is contained in:
Michael Nebel
2022-03-03 15:17:18 +01:00
parent 9c6ed0ade3
commit 81c8cac77e

View File

@@ -10,3 +10,42 @@ class TargetAPI extends Callable {
isRelevantForModels(this)
}
}
private string parameterQualifiedTypeNamesToString(TargetAPI api) {
result =
concat(Parameter p, int i |
p = api.getParameter(i)
|
p.getType().getQualifiedName(), "," order by i
)
}
/** Holds if the summary should apply for all overrides of this. */
private predicate isBaseCallableOrPrototype(TargetAPI api) {
api.getDeclaringType() instanceof Interface
or
exists(Modifiable m | m = [api.(Modifiable), api.(Accessor).getDeclaration()] |
m.isAbstract()
or
api.getDeclaringType().(Modifiable).isAbstract() and m.(Virtualizable).isVirtual()
)
}
/** Gets a string representing, whether the summary should apply for all overrides of this. */
private string getCallableOverride(TargetAPI api) {
if isBaseCallableOrPrototype(api) then result = "true" else result = "false"
}
/** Computes the first 6 columns for CSV rows. */
string asPartialModel(TargetAPI api) {
exists(string namespace, string type |
api.getDeclaringType().hasQualifiedName(namespace, type) and
result =
namespace + ";" //
+ type + ";" //
+ getCallableOverride(api) + ";" //
+ api.getName() + ";" //
+ "(" + parameterQualifiedTypeNamesToString(api) + ")" //
+ /* ext + */ ";" //
)
}