Kotlin: Pull Kotlin type for fields out into its own table

This commit is contained in:
Ian Lynagh
2022-01-27 14:01:33 +00:00
parent 0f7f90dd4e
commit ee008773dc
8 changed files with 26 additions and 16 deletions

View File

@@ -399,11 +399,15 @@ fields(
unique int id: @field,
string nodeName: string ref,
int typeid: @type ref,
int kttypeid: @kt_type ref,
int parentid: @reftype ref,
int sourceid: @field ref
);
fieldsKotlinType(
unique int id: @field ref,
int kttypeid: @kt_type ref
)
constrs(
unique int id: @constructor,
string nodeName: string ref,

View File

@@ -20,7 +20,7 @@ predicate hasName(Element e, string name) {
or
methods(e, name, _, _, _, _, _)
or
fields(e, name, _, _, _, _)
fields(e, name, _, _, _)
or
packages(e, name)
or

View File

@@ -63,7 +63,7 @@ private predicate hasChildElement(Element parent, Element e) {
or
params(e, _, _, _, parent, _)
or
fields(e, _, _, _, parent, _)
fields(e, _, _, parent, _)
or
typeVars(e, _, _, _, parent)
}

View File

@@ -613,13 +613,13 @@ class FieldDeclaration extends ExprParent, @fielddecl, Annotatable {
/** A class or instance field. */
class Field extends Member, ExprParent, @field, Variable {
/** Gets the declared type of this field. */
override Type getType() { fields(this, _, result, _, _, _) }
override Type getType() { fields(this, _, result, _, _) }
/** Gets the Kotlin type of this field. */
override KotlinType getKotlinType() { fields(this, _, _, result, _, _) }
override KotlinType getKotlinType() { fieldsKotlinType(this, result) }
/** Gets the type in which this field is declared. */
override RefType getDeclaringType() { fields(this, _, _, _, result, _) }
override RefType getDeclaringType() { fields(this, _, _, result, _) }
/**
* Gets the field declaration in which this field is declared.
@@ -649,7 +649,7 @@ class Field extends Member, ExprParent, @field, Variable {
*
* For all other fields, the source declaration is the field itself.
*/
Field getSourceDeclaration() { fields(this, _, _, _, _, result) }
Field getSourceDeclaration() { fields(this, _, _, _, result) }
/** Holds if this field is the same as its source declaration. */
predicate isSourceDeclaration() { this.getSourceDeclaration() = this }

View File

@@ -319,7 +319,7 @@ predicate declaresMember(Type t, @member m) {
or
constrs(m, _, _, _, _, t, _)
or
fields(m, _, _, _, t, _)
fields(m, _, _, t, _)
or
enclInReftype(m, t) and
// Since the type `@member` in the dbscheme includes all `@reftype`s,
@@ -1136,11 +1136,11 @@ class EnumType extends Class {
/** Gets the enum constant with the specified name. */
EnumConstant getEnumConstant(string name) {
fields(result, _, _, _, this, _) and result.hasName(name)
fields(result, _, _, this, _) and result.hasName(name)
}
/** Gets an enum constant declared in this enum type. */
EnumConstant getAnEnumConstant() { fields(result, _, _, _, this, _) }
EnumConstant getAnEnumConstant() { fields(result, _, _, this, _) }
override predicate isFinal() {
// JLS 8.9: An enum declaration is implicitly `final` unless it contains