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

Side by Side Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 1917203002: Remove more type casts (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.dart.ast.utilities; 5 library analyzer.src.dart.ast.utilities;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 } 2309 }
2310 return list; 2310 return list;
2311 } 2311 }
2312 2312
2313 @override 2313 @override
2314 Object visitMapLiteral(MapLiteral node) { 2314 Object visitMapLiteral(MapLiteral node) {
2315 HashMap<String, Object> map = new HashMap<String, Object>(); 2315 HashMap<String, Object> map = new HashMap<String, Object>();
2316 for (MapLiteralEntry entry in node.entries) { 2316 for (MapLiteralEntry entry in node.entries) {
2317 Object key = entry.key.accept(this); 2317 Object key = entry.key.accept(this);
2318 Object value = entry.value.accept(this); 2318 Object value = entry.value.accept(this);
2319 if (key is! String || identical(value, NOT_A_CONSTANT)) { 2319 if (key is String && !identical(value, NOT_A_CONSTANT)) {
2320 map[(key as String)] = value;
2321 } else {
2320 return NOT_A_CONSTANT; 2322 return NOT_A_CONSTANT;
2321 } 2323 }
2322 map[(key as String)] = value;
2323 } 2324 }
2324 return map; 2325 return map;
2325 } 2326 }
2326 2327
2327 @override 2328 @override
2328 Object visitMethodInvocation(MethodInvocation node) => visitNode(node); 2329 Object visitMethodInvocation(MethodInvocation node) => visitNode(node);
2329 2330
2330 @override 2331 @override
2331 Object visitNode(AstNode node) => NOT_A_CONSTANT; 2332 Object visitNode(AstNode node) => NOT_A_CONSTANT;
2332 2333
(...skipping 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after
7782 * Safely visit the given [token], printing the [suffix] after the token if it 7783 * Safely visit the given [token], printing the [suffix] after the token if it
7783 * is non-`null`. 7784 * is non-`null`.
7784 */ 7785 */
7785 void _visitTokenWithSuffix(Token token, String suffix) { 7786 void _visitTokenWithSuffix(Token token, String suffix) {
7786 if (token != null) { 7787 if (token != null) {
7787 _writer.print(token.lexeme); 7788 _writer.print(token.lexeme);
7788 _writer.print(suffix); 7789 _writer.print(suffix);
7789 } 7790 }
7790 } 7791 }
7791 } 7792 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698