| OLD | NEW |
| 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 engine.incremental_resolver; | 5 library engine.incremental_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/services/lint.dart'; | 10 import 'package:analyzer/src/services/lint.dart'; |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 _assertEquals(node.identifier.name, element.name); | 465 _assertEquals(node.identifier.name, element.name); |
| 466 } | 466 } |
| 467 // check parameter type specific properties | 467 // check parameter type specific properties |
| 468 if (node is DefaultFormalParameter) { | 468 if (node is DefaultFormalParameter) { |
| 469 Expression nodeDefault = node.defaultValue; | 469 Expression nodeDefault = node.defaultValue; |
| 470 if (nodeDefault == null) { | 470 if (nodeDefault == null) { |
| 471 _assertNull(element.defaultValueCode); | 471 _assertNull(element.defaultValueCode); |
| 472 } else { | 472 } else { |
| 473 _assertEquals(nodeDefault.toSource(), element.defaultValueCode); | 473 _assertEquals(nodeDefault.toSource(), element.defaultValueCode); |
| 474 } | 474 } |
| 475 _assertCompatibleParameter(node.parameter, element); |
| 475 } else if (node is FieldFormalParameter) { | 476 } else if (node is FieldFormalParameter) { |
| 476 _assertTrue(element.isInitializingFormal); | 477 _assertTrue(element.isInitializingFormal); |
| 478 _assertCompatibleParameters(node.parameters, element.parameters); |
| 477 } else if (node is FunctionTypedFormalParameter) { | 479 } else if (node is FunctionTypedFormalParameter) { |
| 480 _assertFalse(element.isInitializingFormal); |
| 478 _assertTrue(element.type is FunctionType); | 481 _assertTrue(element.type is FunctionType); |
| 479 FunctionType elementType = element.type; | 482 FunctionType elementType = element.type; |
| 480 _assertCompatibleParameters(node.parameters, element.parameters); | 483 _assertCompatibleParameters(node.parameters, element.parameters); |
| 481 _assertSameType(node.returnType, elementType.returnType); | 484 _assertSameType(node.returnType, elementType.returnType); |
| 482 } else if (node is SimpleFormalParameter) { | 485 } else if (node is SimpleFormalParameter) { |
| 486 _assertFalse(element.isInitializingFormal); |
| 483 _assertSameType(node.type, element.type); | 487 _assertSameType(node.type, element.type); |
| 484 } | 488 } |
| 485 } | 489 } |
| 486 | 490 |
| 487 void _assertCompatibleParameters( | 491 void _assertCompatibleParameters( |
| 488 FormalParameterList nodes, List<ParameterElement> elements) { | 492 FormalParameterList nodes, List<ParameterElement> elements) { |
| 489 if (nodes == null) { | 493 if (nodes == null) { |
| 490 return _assertEquals(elements.length, 0); | 494 return _assertEquals(elements.length, 0); |
| 491 } | 495 } |
| 492 List<FormalParameter> parameters = nodes.parameters; | 496 List<FormalParameter> parameters = nodes.parameters; |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 found = true; | 1247 found = true; |
| 1244 break; | 1248 break; |
| 1245 } | 1249 } |
| 1246 } | 1250 } |
| 1247 if (!found) { | 1251 if (!found) { |
| 1248 logger.log('Failure: no enclosing function body or executable.'); | 1252 logger.log('Failure: no enclosing function body or executable.'); |
| 1249 return false; | 1253 return false; |
| 1250 } | 1254 } |
| 1251 // fail if a comment change outside the bodies | 1255 // fail if a comment change outside the bodies |
| 1252 if (firstPair.kind == _TokenDifferenceKind.COMMENT) { | 1256 if (firstPair.kind == _TokenDifferenceKind.COMMENT) { |
| 1253 if (beginOffsetOld <= oldNode.offset || beginOffsetNew <= newNode.of
fset) { | 1257 if (beginOffsetOld <= oldNode.offset || |
| 1258 beginOffsetNew <= newNode.offset) { |
| 1254 logger.log('Failure: comment outside a function body.'); | 1259 logger.log('Failure: comment outside a function body.'); |
| 1255 return false; | 1260 return false; |
| 1256 } | 1261 } |
| 1257 } | 1262 } |
| 1258 } | 1263 } |
| 1259 logger.log(() => 'oldNode: $oldNode'); | 1264 logger.log(() => 'oldNode: $oldNode'); |
| 1260 logger.log(() => 'newNode: $newNode'); | 1265 logger.log(() => 'newNode: $newNode'); |
| 1261 // prepare update range | 1266 // prepare update range |
| 1262 _updateOffset = oldNode.offset; | 1267 _updateOffset = oldNode.offset; |
| 1263 _updateEndOld = oldNode.end; | 1268 _updateEndOld = oldNode.end; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 @override | 1810 @override |
| 1806 String toString() => name; | 1811 String toString() => name; |
| 1807 } | 1812 } |
| 1808 | 1813 |
| 1809 class _TokenPair { | 1814 class _TokenPair { |
| 1810 final _TokenDifferenceKind kind; | 1815 final _TokenDifferenceKind kind; |
| 1811 final Token oldToken; | 1816 final Token oldToken; |
| 1812 final Token newToken; | 1817 final Token newToken; |
| 1813 _TokenPair(this.kind, this.oldToken, this.newToken); | 1818 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1814 } | 1819 } |
| OLD | NEW |