Skip to content

Commit c37eebd

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Add a more "isDartCore..." getters to DartType.
Change-Id: I5c192b812e44f9b9f278bc3eaefddd8bc326cf6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110061 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent a082f8c commit c37eebd

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.37.1 (Not yet published)
2+
* Added the getters `isDartCoreList`, `isDartCoreMap`, `isDartCoreSet`, and
3+
`isDartCoreSymbol` to `DartType`.
4+
15
## 0.37.0
26
* Removed deprecated getter `DartType.isUndefined`.
37
* Removed deprecated class `SdkLibrariesReader`.

pkg/analyzer/lib/dart/element/type.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,30 @@ abstract class DartType {
6767
/// dart:core library.
6868
bool get isDartCoreInt;
6969

70+
/// Returns `true` if this type represents the type 'List' defined in the
71+
/// dart:core library.
72+
bool get isDartCoreList;
73+
74+
/// Returns `true` if this type represents the type 'Map' defined in the
75+
/// dart:core library.
76+
bool get isDartCoreMap;
77+
7078
/// Return `true` if this type represents the type 'Null' defined in the
7179
/// dart:core library.
7280
bool get isDartCoreNull;
7381

82+
/// Returns `true` if this type represents the type 'Set' defined in the
83+
/// dart:core library.
84+
bool get isDartCoreSet;
85+
7486
/// Return `true` if this type represents the type 'String' defined in the
7587
/// dart:core library.
7688
bool get isDartCoreString;
7789

90+
/// Returns `true` if this type represents the type 'Symbol' defined in the
91+
/// dart:core library.
92+
bool get isDartCoreSymbol;
93+
7894
/// Return `true` if this type represents the type 'dynamic'.
7995
bool get isDynamic;
8096

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,24 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
15201520
return element.name == "int" && element.library.isDartCore;
15211521
}
15221522

1523+
@override
1524+
bool get isDartCoreList {
1525+
ClassElement element = this.element;
1526+
if (element == null) {
1527+
return false;
1528+
}
1529+
return element.name == "List" && element.library.isDartCore;
1530+
}
1531+
1532+
@override
1533+
bool get isDartCoreMap {
1534+
ClassElement element = this.element;
1535+
if (element == null) {
1536+
return false;
1537+
}
1538+
return element.name == "Map" && element.library.isDartCore;
1539+
}
1540+
15231541
@override
15241542
bool get isDartCoreNull {
15251543
ClassElement element = this.element;
@@ -1529,6 +1547,15 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
15291547
return element.name == "Null" && element.library.isDartCore;
15301548
}
15311549

1550+
@override
1551+
bool get isDartCoreSet {
1552+
ClassElement element = this.element;
1553+
if (element == null) {
1554+
return false;
1555+
}
1556+
return element.name == "Set" && element.library.isDartCore;
1557+
}
1558+
15321559
@override
15331560
bool get isDartCoreString {
15341561
ClassElement element = this.element;
@@ -1538,6 +1565,15 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
15381565
return element.name == "String" && element.library.isDartCore;
15391566
}
15401567

1568+
@override
1569+
bool get isDartCoreSymbol {
1570+
ClassElement element = this.element;
1571+
if (element == null) {
1572+
return false;
1573+
}
1574+
return element.name == "Symbol" && element.library.isDartCore;
1575+
}
1576+
15411577
@override
15421578
bool get isObject => element.supertype == null && !element.isMixin;
15431579

@@ -2831,12 +2867,24 @@ abstract class TypeImpl implements DartType {
28312867
@override
28322868
bool get isDartCoreInt => false;
28332869

2870+
@override
2871+
bool get isDartCoreList => false;
2872+
2873+
@override
2874+
bool get isDartCoreMap => false;
2875+
28342876
@override
28352877
bool get isDartCoreNull => false;
28362878

2879+
@override
2880+
bool get isDartCoreSet => false;
2881+
28372882
@override
28382883
bool get isDartCoreString => false;
28392884

2885+
@override
2886+
bool get isDartCoreSymbol => false;
2887+
28402888
@override
28412889
bool get isDynamic => false;
28422890

pkg/analyzer/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: analyzer
2-
version: 0.37.0
2+
version: 0.37.1-dev
33
author: Dart Team <[email protected]>
44
description: This package provides a library that performs static analysis of Dart code.
55
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer

0 commit comments

Comments
 (0)