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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1925173002: Add a (public) utility method to clean-up code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index b0daf0ed6d440d1d88637cf3917285ab3536632b..6bbe960e9fb5fa489bc76b22345d09ea9a0aabb7 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -517,9 +517,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
if (operator?.type == TokenType.QUESTION_PERIOD) {
return;
}
- while (target is ParenthesizedExpression) {
- target = (target as ParenthesizedExpression).expression;
- }
+ target = target?.unParenthesized;
if (target is MethodInvocation) {
if (target.operator?.type == TokenType.QUESTION_PERIOD) {
_errorReporter.reportErrorForNode(
@@ -818,9 +816,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
* Produce a hint if the given [condition] could have a value of `null`.
*/
void _checkForPossibleNullCondition(Expression condition) {
- while (condition is ParenthesizedExpression) {
- condition = (condition as ParenthesizedExpression).expression;
- }
+ condition = condition?.unParenthesized;
if (condition is BinaryExpression) {
_checkForPossibleNullConditionInBinaryExpression(condition);
} else if (condition is PrefixExpression) {
@@ -5630,16 +5626,12 @@ class ResolverVisitor extends ScopedVisitor {
}
/**
- * Return the static element associated with the given expression whose type can be promoted, or
- * `null` if there is no element whose type can be promoted.
- *
- * @param expression the expression with which the element is associated
- * @return the element associated with the given expression
+ * Return the static element associated with the given expression whose type
+ * can be promoted, or `null` if there is no element whose type can be
+ * promoted.
*/
VariableElement getPromotionStaticElement(Expression expression) {
- while (expression is ParenthesizedExpression) {
- expression = (expression as ParenthesizedExpression).expression;
- }
+ expression = expression?.unParenthesized;
if (expression is SimpleIdentifier) {
Element element = expression.staticElement;
if (element is VariableElement) {
@@ -7177,9 +7169,7 @@ class ResolverVisitor extends ScopedVisitor {
// would eventually turn this into a method on Expression that returns a
// termination indication (normal, abrupt with no exception, abrupt with an
// exception).
- while (expression is ParenthesizedExpression) {
- expression = (expression as ParenthesizedExpression).expression;
- }
+ expression = expression?.unParenthesized;
return expression is ThrowExpression || expression is RethrowExpression;
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698