66 * (`Interface`).
77 *
88 * Reference types can be at the top level (`TopLevelType`) or nested (`NestedType`).
9- * Classes can also be local (`LocalClass`) or anonymous (`AnonymousClass`).
10- * Enumerated types (`EnumType`) are a special kind of class.
9+ * Classes and interfaces can also be local (`LocalClassOrInterface`, `LocalClass`) or anonymous (`AnonymousClass`).
10+ * Enumerated types (`EnumType`) and records (`Record`) are a special kinds of class.
1111 */
1212
1313import Member
@@ -269,7 +269,7 @@ predicate declaresMember(Type t, @member m) {
269269 // Since the type `@member` in the dbscheme includes all `@reftype`s,
270270 // anonymous and local classes need to be excluded here.
271271 not m instanceof AnonymousClass and
272- not m instanceof LocalClass
272+ not m instanceof LocalClassOrInterface
273273}
274274
275275/**
@@ -608,20 +608,10 @@ class SrcRefType extends RefType {
608608}
609609
610610/** A class declaration. */
611- class Class extends RefType , @class {
611+ class Class extends ClassOrInterface , @class {
612612 /** Holds if this class is an anonymous class. */
613613 predicate isAnonymous ( ) { isAnonymClass ( this , _) }
614614
615- /** Holds if this class is a local class. */
616- predicate isLocal ( ) { isLocalClass ( this , _) }
617-
618- /** Holds if this class is package protected, that is, neither public nor private nor protected. */
619- predicate isPackageProtected ( ) {
620- not isPrivate ( ) and
621- not isProtected ( ) and
622- not isPublic ( )
623- }
624-
625615 override RefType getSourceDeclaration ( ) { classes ( this , _, _, result ) }
626616
627617 /**
@@ -630,11 +620,13 @@ class Class extends RefType, @class {
630620 * Note that a class may inherit annotations from super-classes.
631621 */
632622 override Annotation getAnAnnotation ( ) {
633- result = RefType .super .getAnAnnotation ( )
623+ result = ClassOrInterface .super .getAnAnnotation ( )
634624 or
635625 exists ( AnnotationType tp | tp = result .getType ( ) |
636626 tp .isInherited ( ) and
637- not exists ( Annotation ann | ann = RefType .super .getAnAnnotation ( ) | ann .getType ( ) = tp ) and
627+ not exists ( Annotation ann | ann = ClassOrInterface .super .getAnAnnotation ( ) |
628+ ann .getType ( ) = tp
629+ ) and
638630 result = this .getASupertype ( ) .( Class ) .getAnAnnotation ( )
639631 )
640632 }
@@ -643,8 +635,6 @@ class Class extends RefType, @class {
643635}
644636
645637/**
646- * PREVIEW FEATURE in Java 14. Subject to removal in a future release.
647- *
648638 * A record declaration.
649639 */
650640class Record extends Class {
@@ -727,13 +717,20 @@ class AnonymousClass extends NestedClass {
727717 override string getAPrimaryQlClass ( ) { result = "AnonymousClass" }
728718}
729719
730- /** A local class. */
731- class LocalClass extends NestedClass {
732- LocalClass ( ) { this .isLocal ( ) }
720+ /** A local class or interface . */
721+ class LocalClassOrInterface extends NestedType , ClassOrInterface {
722+ LocalClassOrInterface ( ) { this .isLocal ( ) }
733723
734724 /** Gets the statement that declares this local class. */
735725 LocalClassDeclStmt getLocalClassDeclStmt ( ) { isLocalClass ( this , result ) }
736726
727+ override string getAPrimaryQlClass ( ) { result = "LocalClassOrInterface" }
728+ }
729+
730+ /** A local class. */
731+ class LocalClass extends LocalClassOrInterface , NestedClass {
732+ LocalClass ( ) { this .isLocal ( ) }
733+
737734 override string getAPrimaryQlClass ( ) { result = "LocalClass" }
738735}
739736
@@ -847,29 +844,32 @@ class InnerClass extends NestedClass {
847844}
848845
849846/** An interface. */
850- class Interface extends RefType , @interface {
847+ class Interface extends ClassOrInterface , @interface {
851848 override RefType getSourceDeclaration ( ) { interfaces ( this , _, _, result ) }
852849
853850 override predicate isAbstract ( ) {
854851 // JLS 9.1.1.1: "Every interface is implicitly abstract"
855852 any ( )
856853 }
857854
858- /** Holds if this interface is package protected, that is, neither public nor private nor protected. */
859- predicate isPackageProtected ( ) {
860- not isPrivate ( ) and
861- not isProtected ( ) and
862- not isPublic ( )
863- }
864-
865855 override string getAPrimaryQlClass ( ) { result = "Interface" }
866856}
867857
868858/** A class or interface. */
869859class ClassOrInterface extends RefType {
870860 ClassOrInterface ( ) {
871- this instanceof Class or
872- this instanceof Interface
861+ this instanceof @class or
862+ this instanceof @interface
863+ }
864+
865+ /** Holds if this class or interface is local. */
866+ predicate isLocal ( ) { isLocalClass ( this , _) }
867+
868+ /** Holds if this class or interface is package protected, that is, neither public nor private nor protected. */
869+ predicate isPackageProtected ( ) {
870+ not isPrivate ( ) and
871+ not isProtected ( ) and
872+ not isPublic ( )
873873 }
874874}
875875
0 commit comments