Add DB upgrade script to change generic type names to undecorated ones

This commit is contained in:
Tamas Vajk
2021-07-14 14:41:12 +02:00
parent f1a596ee81
commit 6405b89443
6 changed files with 4218 additions and 1 deletions

View File

@@ -56,7 +56,7 @@ private predicate isObjectClass(Class c) { c instanceof ObjectType }
*/
class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_or_ref_type {
/**
* DEPRECATED: use `getUndecoratedName()` instead
* DEPRECATED: use `getUndecoratedName()` instead.
*
* Gets the name of this type without `<...>` brackets, in case it is a generic type.
*/

View File

@@ -1,3 +1,13 @@
/* This is a dummy line to alter the dbscheme, so we can make a database upgrade
* without actually changing any of the dbscheme predicates. It contains a date
* to allow for such updates in the future as well.
*
* 2021-07-14
*
* DO NOT remove this comment carelessly, since it can revert the dbscheme back to a
* previously seen state (matching a previously seen SHA), which would make the upgrade
* mechanism not work properly.
*/
/**
* An invocation of the compiler. Note that more than one file may be

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,27 @@
class Type extends @type {
string toString() { none() }
string getNewName() {
not this instanceof Generic and
types(this, _, result)
or
result = this.(Generic).getUndecoratedName()
}
}
class Generic extends Type {
Generic() {
type_parameters(_, _, this, _) or
type_arguments(_, _, this)
}
string getUndecoratedName() {
exists(string oldName |
types(this, _, oldName) and result = oldName.prefix(min(int i | i = oldName.indexOf("<")))
)
}
}
from Type type, int kind
where types(type, kind, _)
select type, kind, type.getNewName()

View File

@@ -0,0 +1,4 @@
description: Extractor changed to not include angle brackets in generic type names.
compatibility: backwards
types.rel: run types.qlo