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

Unified Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up 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') | pkg/analyzer/lib/src/dart/constant/evaluation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/ast/utilities.dart
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index edd019603f32021ddf2f7214308be9b25f2a1b21..ee59dd66bca58e2a31e122da00f235e1f5638b9c 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -933,9 +933,10 @@ class AstCloner implements AstVisitor<AstNode> {
if (token == null) {
return;
}
- if (token is CommentToken) {
- token = (token as CommentToken).parent;
+ Token nonComment(Token token) {
+ return token is CommentToken ? token.parent : token;
}
+ token = nonComment(token);
if (_lastCloned == null) {
_lastCloned = new Token(TokenType.EOF, -1);
_lastCloned.setNext(_lastCloned);
@@ -2268,7 +2269,7 @@ class ConstantEvaluator extends GeneralizingAstVisitor<Object> {
if (leftOperand is num && rightOperand is num) {
return leftOperand ~/ rightOperand;
}
- } else {}
+ }
break;
}
// TODO(brianwilkerson) This doesn't handle numeric conversions.
@@ -2411,17 +2412,17 @@ class ConstantEvaluator extends GeneralizingAstVisitor<Object> {
*/
Object _getConstantValue(Element element) {
// TODO(brianwilkerson) Implement this
- if (element is FieldElement) {
- FieldElement field = element;
- if (field.isStatic && field.isConst) {
- //field.getConstantValue();
- }
- // } else if (element instanceof VariableElement) {
- // VariableElement variable = (VariableElement) element;
- // if (variable.isStatic() && variable.isConst()) {
- // //variable.getConstantValue();
- // }
- }
+// if (element is FieldElement) {
+// FieldElement field = element;
+// if (field.isStatic && field.isConst) {
+// //field.getConstantValue();
+// }
+// // } else if (element instanceof VariableElement) {
+// // VariableElement variable = (VariableElement) element;
+// // if (variable.isStatic() && variable.isConst()) {
+// // //variable.getConstantValue();
+// // }
+// }
return NOT_A_CONSTANT;
}
}
@@ -2504,17 +2505,14 @@ class ElementLocator_ElementMapper extends GeneralizingAstVisitor<Element> {
@override
Element visitIdentifier(Identifier node) {
AstNode parent = node.parent;
- // Type name in Annotation
if (parent is Annotation) {
- Annotation annotation = parent;
- if (identical(annotation.name, node) &&
- annotation.constructorName == null) {
- return annotation.element;
+ // Type name in Annotation
+ if (identical(parent.name, node) && parent.constructorName == null) {
+ return parent.element;
}
- }
- // Extra work to map Constructor Declarations to their associated
- // Constructor Elements
- if (parent is ConstructorDeclaration) {
+ } else if (parent is ConstructorDeclaration) {
+ // Extra work to map Constructor Declarations to their associated
+ // Constructor Elements
Identifier returnType = parent.returnType;
if (identical(returnType, node)) {
SimpleIdentifier name = parent.name;
@@ -2526,8 +2524,7 @@ class ElementLocator_ElementMapper extends GeneralizingAstVisitor<Element> {
return element.unnamedConstructor;
}
}
- }
- if (parent is LibraryIdentifier) {
+ } else if (parent is LibraryIdentifier) {
AstNode grandParent = parent.parent;
if (grandParent is PartOfDirective) {
Element element = grandParent.element;
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/dart/constant/evaluation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698