@@ -896,21 +896,28 @@ class ArrayTypeExpr extends @array_typeexpr, TypeExpr {
896
896
override string getAPrimaryQlClass ( ) { result = "ArrayTypeExpr" }
897
897
}
898
898
899
+ private class RawUnionOrIntersectionTypeExpr = @union_typeexpr or @intersection_typeexpr;
900
+
899
901
/**
900
- * A union type, such as `string|number|boolean`.
902
+ * A union or intersection type, such as `string|number|boolean` or `A & B `.
901
903
*/
902
- class UnionTypeExpr extends @union_typeexpr , TypeExpr {
903
- /** Gets the `n`th type in the union, starting at 0. */
904
+ class UnionOrIntersectionTypeExpr extends RawUnionOrIntersectionTypeExpr , TypeExpr {
905
+ /** Gets the `n`th type in the union or intersection , starting at 0. */
904
906
TypeExpr getElementType ( int n ) { result = this .getChildTypeExpr ( n ) }
905
907
906
- /** Gets any of the types in the union. */
908
+ /** Gets any of the types in the union or intersection . */
907
909
TypeExpr getAnElementType ( ) { result = this .getElementType ( _) }
908
910
909
- /** Gets the number of types in the union. This is always at least two. */
911
+ /** Gets the number of types in the union or intersection . This is always at least two. */
910
912
int getNumElementType ( ) { result = count ( this .getAnElementType ( ) ) }
911
913
912
914
override TypeExpr getAnUnderlyingType ( ) { result = this .getAnElementType ( ) .getAnUnderlyingType ( ) }
915
+ }
913
916
917
+ /**
918
+ * A union type, such as `string|number|boolean`.
919
+ */
920
+ class UnionTypeExpr extends @union_typeexpr, UnionOrIntersectionTypeExpr {
914
921
override string getAPrimaryQlClass ( ) { result = "UnionTypeExpr" }
915
922
}
916
923
@@ -932,18 +939,7 @@ class IndexedAccessTypeExpr extends @indexed_access_typeexpr, TypeExpr {
932
939
*
933
940
* In general, there are can more than two operands to an intersection type.
934
941
*/
935
- class IntersectionTypeExpr extends @intersection_typeexpr, TypeExpr {
936
- /** Gets the `n`th operand of the intersection type, starting at 0. */
937
- TypeExpr getElementType ( int n ) { result = this .getChildTypeExpr ( n ) }
938
-
939
- /** Gets any of the operands to the intersection type. */
940
- TypeExpr getAnElementType ( ) { result = this .getElementType ( _) }
941
-
942
- /** Gets the number of operands to the intersection type. This is always at least two. */
943
- int getNumElementType ( ) { result = count ( this .getAnElementType ( ) ) }
944
-
945
- override TypeExpr getAnUnderlyingType ( ) { result = this .getAnElementType ( ) .getAnUnderlyingType ( ) }
946
-
942
+ class IntersectionTypeExpr extends @intersection_typeexpr, UnionOrIntersectionTypeExpr {
947
943
override string getAPrimaryQlClass ( ) { result = "IntersectionTypeExpr" }
948
944
}
949
945
0 commit comments