| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 element = _findElement(_enclosingUnit.accessors, name); | 265 element = _findElement(_enclosingUnit.accessors, name); |
| 266 } | 266 } |
| 267 // process element | 267 // process element |
| 268 _processElement(element); | 268 _processElement(element); |
| 269 _assertSameAnnotations(node, element); | 269 _assertSameAnnotations(node, element); |
| 270 _assertFalse(element.isSynthetic); | 270 _assertFalse(element.isSynthetic); |
| 271 _assertSameType(node.returnType, element.returnType); | 271 _assertSameType(node.returnType, element.returnType); |
| 272 _assertCompatibleParameters( | 272 _assertCompatibleParameters( |
| 273 node.functionExpression.parameters, | 273 node.functionExpression.parameters, |
| 274 element.parameters); | 274 element.parameters); |
| 275 _assertBodyModifiers(node.functionExpression.body, element); |
| 275 // matches, update the existing element | 276 // matches, update the existing element |
| 276 ExecutableElement newElement = node.element; | 277 ExecutableElement newElement = node.element; |
| 277 node.name.staticElement = element; | 278 node.name.staticElement = element; |
| 278 node.functionExpression.element = element; | 279 node.functionExpression.element = element; |
| 279 _setLocalElements(element, newElement); | 280 _setLocalElements(element, newElement); |
| 280 } | 281 } |
| 281 | 282 |
| 282 @override | 283 @override |
| 283 visitFunctionTypeAlias(FunctionTypeAlias node) { | 284 visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 284 String name = node.name.name; | 285 String name = node.name.name; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 element = _findElement(_enclosingClass.accessors, name); | 339 element = _findElement(_enclosingClass.accessors, name); |
| 339 } | 340 } |
| 340 // process element | 341 // process element |
| 341 ExecutableElement newElement = node.element; | 342 ExecutableElement newElement = node.element; |
| 342 try { | 343 try { |
| 343 _assertNotNull(element); | 344 _assertNotNull(element); |
| 344 _assertSameAnnotations(node, element); | 345 _assertSameAnnotations(node, element); |
| 345 _assertEquals(node.isStatic, element.isStatic); | 346 _assertEquals(node.isStatic, element.isStatic); |
| 346 _assertSameType(node.returnType, element.returnType); | 347 _assertSameType(node.returnType, element.returnType); |
| 347 _assertCompatibleParameters(node.parameters, element.parameters); | 348 _assertCompatibleParameters(node.parameters, element.parameters); |
| 349 _assertBodyModifiers(node.body, element); |
| 348 _removedElements.remove(element); | 350 _removedElements.remove(element); |
| 349 // matches, update the existing element | 351 // matches, update the existing element |
| 350 node.name.staticElement = element; | 352 node.name.staticElement = element; |
| 351 _setLocalElements(element, newElement); | 353 _setLocalElements(element, newElement); |
| 352 } on _DeclarationMismatchException catch (e) { | 354 } on _DeclarationMismatchException catch (e) { |
| 353 _addedElements.add(newElement); | 355 _addedElements.add(newElement); |
| 354 _removeElement(element); | 356 _removeElement(element); |
| 355 // add new element | 357 // add new element |
| 356 if (newElement is MethodElement) { | 358 if (newElement is MethodElement) { |
| 357 List<MethodElement> methods = _enclosingClass.methods; | 359 List<MethodElement> methods = _enclosingClass.methods; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 417 } |
| 416 } | 418 } |
| 417 | 419 |
| 418 @override | 420 @override |
| 419 visitWithClause(WithClause node) { | 421 visitWithClause(WithClause node) { |
| 420 List<TypeName> nodes = node.mixinTypes; | 422 List<TypeName> nodes = node.mixinTypes; |
| 421 List<InterfaceType> types = _enclosingClass.mixins; | 423 List<InterfaceType> types = _enclosingClass.mixins; |
| 422 _assertSameTypes(nodes, types); | 424 _assertSameTypes(nodes, types); |
| 423 } | 425 } |
| 424 | 426 |
| 427 /** |
| 428 * Asserts that [body] has async / generator modifiers compatible with the |
| 429 * given [element]. |
| 430 */ |
| 431 void _assertBodyModifiers(FunctionBody body, ExecutableElementImpl element) { |
| 432 _assertEquals(body.isSynchronous, element.isSynchronous); |
| 433 _assertEquals(body.isGenerator, element.isGenerator); |
| 434 } |
| 435 |
| 425 void _assertCombinators(List<Combinator> nodeCombinators, | 436 void _assertCombinators(List<Combinator> nodeCombinators, |
| 426 List<NamespaceCombinator> elementCombinators) { | 437 List<NamespaceCombinator> elementCombinators) { |
| 427 // prepare shown/hidden names in the element | 438 // prepare shown/hidden names in the element |
| 428 Set<String> showNames = new Set<String>(); | 439 Set<String> showNames = new Set<String>(); |
| 429 Set<String> hideNames = new Set<String>(); | 440 Set<String> hideNames = new Set<String>(); |
| 430 for (NamespaceCombinator combinator in elementCombinators) { | 441 for (NamespaceCombinator combinator in elementCombinators) { |
| 431 if (combinator is ShowElementCombinator) { | 442 if (combinator is ShowElementCombinator) { |
| 432 showNames.addAll(combinator.shownNames); | 443 showNames.addAll(combinator.shownNames); |
| 433 } else if (combinator is HideElementCombinator) { | 444 } else if (combinator is HideElementCombinator) { |
| 434 hideNames.addAll(combinator.hiddenNames); | 445 hideNames.addAll(combinator.hiddenNames); |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 String toString() => name; | 1871 String toString() => name; |
| 1861 } | 1872 } |
| 1862 | 1873 |
| 1863 | 1874 |
| 1864 class _TokenPair { | 1875 class _TokenPair { |
| 1865 final _TokenDifferenceKind kind; | 1876 final _TokenDifferenceKind kind; |
| 1866 final Token oldToken; | 1877 final Token oldToken; |
| 1867 final Token newToken; | 1878 final Token newToken; |
| 1868 _TokenPair(this.kind, this.oldToken, this.newToken); | 1879 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1869 } | 1880 } |
| OLD | NEW |