@@ -517,7 +517,12 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
517
517
/** Holds if this is a top-level type, which is not nested inside any other types. */
518
518
predicate isTopLevel ( ) { this instanceof TopLevelType }
519
519
520
- /** Holds if this type is declared in a specified package with the specified name. */
520
+ /**
521
+ * Holds if this type is declared in a specified package with the specified name.
522
+ *
523
+ * For nested types the name of the nested type is prefixed with a `$` and appended
524
+ * to the name of the enclosing type, which might be a nested type as well.
525
+ */
521
526
predicate hasQualifiedName ( string package , string type ) {
522
527
this .getPackage ( ) .hasName ( package ) and type = this .nestedName ( )
523
528
}
@@ -532,15 +537,26 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
532
537
}
533
538
534
539
/**
535
- * Gets the qualified name of this type.
540
+ * Gets the qualified name of this type, consisting of the package name followed by
541
+ * a `.` and the name of this type.
542
+ *
543
+ * For nested types the name of the nested type is prefixed with a `$` and appended
544
+ * to the name of the enclosing type, which might be a nested type as well. For example:
545
+ * `java.lang.Thread$State`.
536
546
*/
537
547
string getQualifiedName ( ) {
538
548
exists ( string pkgName | pkgName = getPackage ( ) .getName ( ) |
539
549
if pkgName = "" then result = nestedName ( ) else result = pkgName + "." + nestedName ( )
540
550
)
541
551
}
542
552
543
- /** Gets the nested name of this type. */
553
+ /**
554
+ * Gets the nested name of this type.
555
+ *
556
+ * If this type is not a nested type, the result is the same as `getName()`.
557
+ * Otherwise the name of the nested type is prefixed with a `$` and appended to
558
+ * the name of the enclosing type, which might be a nested type as well.
559
+ */
544
560
string nestedName ( ) {
545
561
not this instanceof NestedType and result = this .getName ( )
546
562
or
@@ -788,6 +804,21 @@ class NestedType extends RefType {
788
804
}
789
805
}
790
806
807
+ /**
808
+ * A nested type which is a direct member of the enclosing type,
809
+ * that is, neither an anonymous nor local class.
810
+ */
811
+ class MemberType extends NestedType , Member {
812
+ /**
813
+ * Gets the qualified name of this member type.
814
+ *
815
+ * The qualified name consists of the package name, a `.`, the name of the declaring
816
+ * type (which might be a nested or member type as well), followed by a `$` and the
817
+ * name of this member type. For example: `java.lang.Thread$State`.
818
+ */
819
+ override string getQualifiedName ( ) { result = NestedType .super .getQualifiedName ( ) }
820
+ }
821
+
791
822
/**
792
823
* A class declared within another type.
793
824
*
@@ -797,8 +828,9 @@ class NestedType extends RefType {
797
828
class NestedClass extends NestedType , Class { }
798
829
799
830
/**
800
- * An inner class is a nested class that is neither
801
- * explicitly nor implicitly declared static.
831
+ * An inner class is a nested class that is neither explicitly nor
832
+ * implicitly declared static. This includes anonymous and local
833
+ * classes.
802
834
*/
803
835
class InnerClass extends NestedClass {
804
836
InnerClass ( ) { not this .isStatic ( ) }
0 commit comments