Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1732383002: Modernize ElementAnnotationImpl.isX getters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 1885c9c35f2e5d54f3c1011a9a5c203d49d661f0..6f4190e072656c5735091b3da79a9fcb22db00c7 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1591,7 +1591,7 @@ class ElementAnnotationImpl implements ElementAnnotation {
Element element;
/**
- * The compliation unit in which this annotation appears.
+ * The compilation unit in which this annotation appears.
*/
final CompilationUnitElementImpl compilationUnit;
@@ -1622,65 +1622,33 @@ class ElementAnnotationImpl implements ElementAnnotation {
@override
bool get isDeprecated {
- if (element != null) {
- LibraryElement library = element.library;
- if (library != null && library.isDartCore) {
- if (element is ConstructorElement) {
- ConstructorElement constructorElement = element as ConstructorElement;
- if (constructorElement.enclosingElement.name ==
- _DEPRECATED_CLASS_NAME) {
- return true;
- }
- } else if (element is PropertyAccessorElement &&
- element.name == _DEPRECATED_VARIABLE_NAME) {
- return true;
- }
+ if (element?.library?.isDartCore == true) {
Brian Wilkerson 2016/02/25 17:02:12 I'm obviously not used to the null-aware operators
+ if (element is ConstructorElement) {
+ return element.enclosingElement.name == _DEPRECATED_CLASS_NAME;
+ } else if (element is PropertyAccessorElement) {
+ return element.name == _DEPRECATED_VARIABLE_NAME;
}
}
return false;
}
@override
- bool get isOverride {
- if (element != null) {
- LibraryElement library = element.library;
- if (library != null && library.isDartCore) {
- if (element is PropertyAccessorElement &&
- element.name == _OVERRIDE_VARIABLE_NAME) {
- return true;
- }
- }
- }
- return false;
- }
+ bool get isOverride =>
+ element is PropertyAccessorElement &&
+ element.name == _OVERRIDE_VARIABLE_NAME &&
+ element.library?.isDartCore == true;
@override
- bool get isProtected {
- if (element != null) {
- LibraryElement library = element.library;
- if (library != null && library.name == _META_LIB_NAME) {
- if (element is PropertyAccessorElement &&
- element.name == _PROTECTED_VARIABLE_NAME) {
- return true;
- }
- }
- }
- return false;
- }
+ bool get isProtected =>
+ element is PropertyAccessorElement &&
+ element.name == _PROTECTED_VARIABLE_NAME &&
+ element.library?.name == _META_LIB_NAME;
@override
- bool get isProxy {
- if (element != null) {
- LibraryElement library = element.library;
- if (library != null && library.isDartCore) {
- if (element is PropertyAccessorElement &&
- element.name == PROXY_VARIABLE_NAME) {
- return true;
- }
- }
- }
- return false;
- }
+ bool get isProxy =>
+ element is PropertyAccessorElement &&
+ element.name == PROXY_VARIABLE_NAME &&
+ element.library?.isDartCore == true;
/**
* Get the library containing this annotation.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698