Add a more "isDartCore..." getters to DartType.

Change-Id: I5c192b812e44f9b9f278bc3eaefddd8bc326cf6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Paul Berry 2019-07-23 20:56:34 +00:00 committed by commit-bot@chromium.org
parent a082f8ce65
commit c37eebd011
4 changed files with 69 additions and 1 deletions

View file

@ -1,3 +1,7 @@
## 0.37.1 (Not yet published)
* Added the getters `isDartCoreList`, `isDartCoreMap`, `isDartCoreSet`, and
`isDartCoreSymbol` to `DartType`.
## 0.37.0
* Removed deprecated getter `DartType.isUndefined`.
* Removed deprecated class `SdkLibrariesReader`.

View file

@ -67,14 +67,30 @@ abstract class DartType {
/// dart:core library.
bool get isDartCoreInt;
/// Returns `true` if this type represents the type 'List' defined in the
/// dart:core library.
bool get isDartCoreList;
/// Returns `true` if this type represents the type 'Map' defined in the
/// dart:core library.
bool get isDartCoreMap;
/// Return `true` if this type represents the type 'Null' defined in the
/// dart:core library.
bool get isDartCoreNull;
/// Returns `true` if this type represents the type 'Set' defined in the
/// dart:core library.
bool get isDartCoreSet;
/// Return `true` if this type represents the type 'String' defined in the
/// dart:core library.
bool get isDartCoreString;
/// Returns `true` if this type represents the type 'Symbol' defined in the
/// dart:core library.
bool get isDartCoreSymbol;
/// Return `true` if this type represents the type 'dynamic'.
bool get isDynamic;

View file

@ -1520,6 +1520,24 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return element.name == "int" && element.library.isDartCore;
}
@override
bool get isDartCoreList {
ClassElement element = this.element;
if (element == null) {
return false;
}
return element.name == "List" && element.library.isDartCore;
}
@override
bool get isDartCoreMap {
ClassElement element = this.element;
if (element == null) {
return false;
}
return element.name == "Map" && element.library.isDartCore;
}
@override
bool get isDartCoreNull {
ClassElement element = this.element;
@ -1529,6 +1547,15 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return element.name == "Null" && element.library.isDartCore;
}
@override
bool get isDartCoreSet {
ClassElement element = this.element;
if (element == null) {
return false;
}
return element.name == "Set" && element.library.isDartCore;
}
@override
bool get isDartCoreString {
ClassElement element = this.element;
@ -1538,6 +1565,15 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return element.name == "String" && element.library.isDartCore;
}
@override
bool get isDartCoreSymbol {
ClassElement element = this.element;
if (element == null) {
return false;
}
return element.name == "Symbol" && element.library.isDartCore;
}
@override
bool get isObject => element.supertype == null && !element.isMixin;
@ -2831,12 +2867,24 @@ abstract class TypeImpl implements DartType {
@override
bool get isDartCoreInt => false;
@override
bool get isDartCoreList => false;
@override
bool get isDartCoreMap => false;
@override
bool get isDartCoreNull => false;
@override
bool get isDartCoreSet => false;
@override
bool get isDartCoreString => false;
@override
bool get isDartCoreSymbol => false;
@override
bool get isDynamic => false;

View file

@ -1,5 +1,5 @@
name: analyzer
version: 0.37.0
version: 0.37.1-dev
author: Dart Team <misc@dartlang.org>
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer