| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } else { | 261 } else { |
| 262 element = _findElement(_enclosingUnit.accessors, name); | 262 element = _findElement(_enclosingUnit.accessors, name); |
| 263 } | 263 } |
| 264 // process element | 264 // process element |
| 265 _processElement(element); | 265 _processElement(element); |
| 266 _assertSameAnnotations(node, element); | 266 _assertSameAnnotations(node, element); |
| 267 _assertFalse(element.isSynthetic); | 267 _assertFalse(element.isSynthetic); |
| 268 _assertSameType(node.returnType, element.returnType); | 268 _assertSameType(node.returnType, element.returnType); |
| 269 _assertCompatibleParameters( | 269 _assertCompatibleParameters( |
| 270 node.functionExpression.parameters, element.parameters); | 270 node.functionExpression.parameters, element.parameters); |
| 271 _assertBodyModifiers(node.functionExpression.body, element); | 271 _assertBody(node.functionExpression.body, element); |
| 272 // matches, update the existing element | 272 // matches, update the existing element |
| 273 ExecutableElement newElement = node.element; | 273 ExecutableElement newElement = node.element; |
| 274 node.name.staticElement = element; | 274 node.name.staticElement = element; |
| 275 node.functionExpression.element = element; | 275 node.functionExpression.element = element; |
| 276 _setLocalElements(element, newElement); | 276 _setLocalElements(element, newElement); |
| 277 } | 277 } |
| 278 | 278 |
| 279 @override | 279 @override |
| 280 visitFunctionTypeAlias(FunctionTypeAlias node) { | 280 visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 281 String name = node.name.name; | 281 String name = node.name.name; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 element = _findElement(_enclosingClass.accessors, name); | 335 element = _findElement(_enclosingClass.accessors, name); |
| 336 } | 336 } |
| 337 // process element | 337 // process element |
| 338 ExecutableElement newElement = node.element; | 338 ExecutableElement newElement = node.element; |
| 339 try { | 339 try { |
| 340 _assertNotNull(element); | 340 _assertNotNull(element); |
| 341 _assertSameAnnotations(node, element); | 341 _assertSameAnnotations(node, element); |
| 342 _assertEquals(node.isStatic, element.isStatic); | 342 _assertEquals(node.isStatic, element.isStatic); |
| 343 _assertSameType(node.returnType, element.returnType); | 343 _assertSameType(node.returnType, element.returnType); |
| 344 _assertCompatibleParameters(node.parameters, element.parameters); | 344 _assertCompatibleParameters(node.parameters, element.parameters); |
| 345 _assertBodyModifiers(node.body, element); | 345 _assertBody(node.body, element); |
| 346 _removedElements.remove(element); | 346 _removedElements.remove(element); |
| 347 // matches, update the existing element | 347 // matches, update the existing element |
| 348 node.name.staticElement = element; | 348 node.name.staticElement = element; |
| 349 _setLocalElements(element, newElement); | 349 _setLocalElements(element, newElement); |
| 350 } on _DeclarationMismatchException { | 350 } on _DeclarationMismatchException { |
| 351 _addedElements.add(newElement); | 351 _addedElements.add(newElement); |
| 352 _removeElement(element); | 352 _removeElement(element); |
| 353 // add new element | 353 // add new element |
| 354 if (newElement is MethodElement) { | 354 if (newElement is MethodElement) { |
| 355 List<MethodElement> methods = _enclosingClass.methods; | 355 List<MethodElement> methods = _enclosingClass.methods; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 413 } |
| 414 | 414 |
| 415 @override | 415 @override |
| 416 visitWithClause(WithClause node) { | 416 visitWithClause(WithClause node) { |
| 417 List<TypeName> nodes = node.mixinTypes; | 417 List<TypeName> nodes = node.mixinTypes; |
| 418 List<InterfaceType> types = _enclosingClass.mixins; | 418 List<InterfaceType> types = _enclosingClass.mixins; |
| 419 _assertSameTypes(nodes, types); | 419 _assertSameTypes(nodes, types); |
| 420 } | 420 } |
| 421 | 421 |
| 422 /** | 422 /** |
| 423 * Asserts that [body] has async / generator modifiers compatible with the | 423 * Assert that the given [body] is compatible with the given [element]. |
| 424 * given [element]. | 424 * It should not be empty if the [element] is not an abstract class member. |
| 425 * If it is present, it should have the same async / generator modifiers. |
| 425 */ | 426 */ |
| 426 void _assertBodyModifiers(FunctionBody body, ExecutableElementImpl element) { | 427 void _assertBody(FunctionBody body, ExecutableElementImpl element) { |
| 427 _assertEquals(body.isSynchronous, element.isSynchronous); | 428 if (body is EmptyFunctionBody) { |
| 428 _assertEquals(body.isGenerator, element.isGenerator); | 429 _assertTrue(element.isAbstract); |
| 430 } else { |
| 431 _assertFalse(element.isAbstract); |
| 432 _assertEquals(body.isSynchronous, element.isSynchronous); |
| 433 _assertEquals(body.isGenerator, element.isGenerator); |
| 434 } |
| 429 } | 435 } |
| 430 | 436 |
| 431 void _assertCombinators(List<Combinator> nodeCombinators, | 437 void _assertCombinators(List<Combinator> nodeCombinators, |
| 432 List<NamespaceCombinator> elementCombinators) { | 438 List<NamespaceCombinator> elementCombinators) { |
| 433 // prepare shown/hidden names in the element | 439 // prepare shown/hidden names in the element |
| 434 Set<String> showNames = new Set<String>(); | 440 Set<String> showNames = new Set<String>(); |
| 435 Set<String> hideNames = new Set<String>(); | 441 Set<String> hideNames = new Set<String>(); |
| 436 for (NamespaceCombinator combinator in elementCombinators) { | 442 for (NamespaceCombinator combinator in elementCombinators) { |
| 437 if (combinator is ShowElementCombinator) { | 443 if (combinator is ShowElementCombinator) { |
| 438 showNames.addAll(combinator.shownNames); | 444 showNames.addAll(combinator.shownNames); |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 @override | 1816 @override |
| 1811 String toString() => name; | 1817 String toString() => name; |
| 1812 } | 1818 } |
| 1813 | 1819 |
| 1814 class _TokenPair { | 1820 class _TokenPair { |
| 1815 final _TokenDifferenceKind kind; | 1821 final _TokenDifferenceKind kind; |
| 1816 final Token oldToken; | 1822 final Token oldToken; |
| 1817 final Token newToken; | 1823 final Token newToken; |
| 1818 _TokenPair(this.kind, this.oldToken, this.newToken); | 1824 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1819 } | 1825 } |
| OLD | NEW |