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

Side by Side Diff: pkg/analyzer/lib/src/task/strong_mode.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.task.strong_mode; 5 library analyzer.src.task.strong_mode;
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/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
11 import 'package:analyzer/dart/element/element.dart'; 11 import 'package:analyzer/dart/element/element.dart';
12 import 'package:analyzer/dart/element/type.dart'; 12 import 'package:analyzer/dart/element/type.dart';
13 import 'package:analyzer/src/dart/element/element.dart'; 13 import 'package:analyzer/src/dart/element/element.dart';
14 import 'package:analyzer/src/dart/element/type.dart'; 14 import 'package:analyzer/src/dart/element/type.dart';
15 import 'package:analyzer/src/dart/resolver/inheritance_manager.dart';
15 import 'package:analyzer/src/generated/resolver.dart' 16 import 'package:analyzer/src/generated/resolver.dart'
16 show TypeProvider, InheritanceManager; 17 show TypeProvider, InheritanceManager;
17 import 'package:analyzer/src/generated/type_system.dart'; 18 import 'package:analyzer/src/generated/type_system.dart';
18 import 'package:analyzer/src/generated/utilities_dart.dart'; 19 import 'package:analyzer/src/generated/utilities_dart.dart';
19 import 'package:analyzer/src/dart/resolver/inheritance_manager.dart';
20 20
21 /** 21 /**
22 * Sets the type of the field. This is stored in the field itself, and the 22 * Sets the type of the field. This is stored in the field itself, and the
23 * synthetic getter/setter types. 23 * synthetic getter/setter types.
24 */ 24 */
25 void setFieldType(VariableElement field, DartType newType) { 25 void setFieldType(VariableElement field, DartType newType) {
26 (field as VariableElementImpl).type = newType; 26 (field as VariableElementImpl).type = newType;
27 if (field.initializer != null) { 27 if (field.initializer != null) {
28 (field.initializer as ExecutableElementImpl).returnType = newType; 28 (field.initializer as ExecutableElementImpl).returnType = newType;
29 } 29 }
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 /** 463 /**
464 * Initialize a newly created gatherer to gather all of the variables that 464 * Initialize a newly created gatherer to gather all of the variables that
465 * pass the given [filter] (or all variables if no filter is provided). 465 * pass the given [filter] (or all variables if no filter is provided).
466 */ 466 */
467 VariableGatherer([this.filter = null]); 467 VariableGatherer([this.filter = null]);
468 468
469 @override 469 @override
470 void visitSimpleIdentifier(SimpleIdentifier node) { 470 void visitSimpleIdentifier(SimpleIdentifier node) {
471 if (!node.inDeclarationContext()) { 471 if (!node.inDeclarationContext()) {
472 Element element = node.staticElement; 472 Element nonAccessor(Element element) {
473 if (element is PropertyAccessorElement && element.isSynthetic) { 473 if (element is PropertyAccessorElement && element.isSynthetic) {
474 element = (element as PropertyAccessorElement).variable; 474 return element.variable;
475 }
476 return element;
475 } 477 }
478 Element element = nonAccessor(node.staticElement);
476 if (element is VariableElement && (filter == null || filter(element))) { 479 if (element is VariableElement && (filter == null || filter(element))) {
477 results.add(element); 480 results.add(element);
478 } 481 }
479 } 482 }
480 } 483 }
481 } 484 }
482 485
483 /** 486 /**
484 * A class of exception that is not used anywhere else. 487 * A class of exception that is not used anywhere else.
485 */ 488 */
486 class _CycleException implements Exception {} 489 class _CycleException implements Exception {}
OLDNEW
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698