| 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 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 visitVariableDeclaration(VariableDeclaration node) { | 386 visitVariableDeclaration(VariableDeclaration node) { |
| 387 // prepare variable | 387 // prepare variable |
| 388 String name = node.name.name; | 388 String name = node.name.name; |
| 389 PropertyInducingElement element; | 389 PropertyInducingElement element; |
| 390 if (_inTopLevelVariableDeclaration) { | 390 if (_inTopLevelVariableDeclaration) { |
| 391 element = _findElement(_enclosingUnit.topLevelVariables, name); | 391 element = _findElement(_enclosingUnit.topLevelVariables, name); |
| 392 } else { | 392 } else { |
| 393 element = _findElement(_enclosingClass.fields, name); | 393 element = _findElement(_enclosingClass.fields, name); |
| 394 } | 394 } |
| 395 // verify | 395 // verify |
| 396 PropertyInducingElement newElement = node.name.staticElement; |
| 396 _assertNotNull(element); | 397 _assertNotNull(element); |
| 397 _processElement(element); | 398 _processElement(element); |
| 398 _assertEquals(node.isConst, element.isConst); | 399 _assertEquals(node.isConst, element.isConst); |
| 399 _assertEquals(node.isFinal, element.isFinal); | 400 _assertEquals(node.isFinal, element.isFinal); |
| 400 if (_enclosingFieldNode != null) { | 401 if (_enclosingFieldNode != null) { |
| 401 _assertEquals(_enclosingFieldNode.isStatic, element.isStatic); | 402 _assertEquals(_enclosingFieldNode.isStatic, element.isStatic); |
| 402 } | 403 } |
| 403 _assertSameType( | 404 _assertSameType( |
| 404 (node.parent as VariableDeclarationList).type, | 405 (node.parent as VariableDeclarationList).type, |
| 405 element.type); | 406 element.type); |
| 406 // matches, restore the existing element | 407 // matches, restore the existing element |
| 407 node.name.staticElement = element; | 408 node.name.staticElement = element; |
| 409 if (element is VariableElementImpl) { |
| 410 (element as VariableElementImpl).initializer = newElement.initializer; |
| 411 } |
| 408 } | 412 } |
| 409 | 413 |
| 410 @override | 414 @override |
| 411 visitWithClause(WithClause node) { | 415 visitWithClause(WithClause node) { |
| 412 List<TypeName> nodes = node.mixinTypes; | 416 List<TypeName> nodes = node.mixinTypes; |
| 413 List<InterfaceType> types = _enclosingClass.mixins; | 417 List<InterfaceType> types = _enclosingClass.mixins; |
| 414 _assertSameTypes(nodes, types); | 418 _assertSameTypes(nodes, types); |
| 415 } | 419 } |
| 416 | 420 |
| 417 void _assertCombinators(List<Combinator> nodeCombinators, | 421 void _assertCombinators(List<Combinator> nodeCombinators, |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 * | 908 * |
| 905 * [node] - the node being tested. | 909 * [node] - the node being tested. |
| 906 */ | 910 */ |
| 907 bool _canBeResolved(AstNode node) => | 911 bool _canBeResolved(AstNode node) => |
| 908 node is ClassDeclaration || | 912 node is ClassDeclaration || |
| 909 node is ClassTypeAlias || | 913 node is ClassTypeAlias || |
| 910 node is CompilationUnit || | 914 node is CompilationUnit || |
| 911 node is ConstructorDeclaration || | 915 node is ConstructorDeclaration || |
| 912 node is FunctionDeclaration || | 916 node is FunctionDeclaration || |
| 913 node is FunctionTypeAlias || | 917 node is FunctionTypeAlias || |
| 914 node is MethodDeclaration; | 918 node is MethodDeclaration || |
| 919 node is TopLevelVariableDeclaration; |
| 915 | 920 |
| 916 void _fillResolutionQueue(DeclarationMatcher matcher) { | 921 void _fillResolutionQueue(DeclarationMatcher matcher) { |
| 917 HashSet<Element> removedElements = matcher._removedElements; | 922 HashSet<Element> removedElements = matcher._removedElements; |
| 918 logger.log('${removedElements.length} elements removed'); | 923 logger.log('${removedElements.length} elements removed'); |
| 919 for (Element removedElement in removedElements) { | 924 for (Element removedElement in removedElements) { |
| 920 AnalysisContextImpl context = removedElement.context; | 925 AnalysisContextImpl context = removedElement.context; |
| 921 IntSet users = removedElement.users; | 926 IntSet users = removedElement.users; |
| 922 while (!users.isEmpty) { | 927 while (!users.isEmpty) { |
| 923 int id = users.remove(); | 928 int id = users.remove(); |
| 924 Element removedElementUser = context.findElementById(id); | 929 Element removedElementUser = context.findElementById(id); |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 String toString() => name; | 1807 String toString() => name; |
| 1803 } | 1808 } |
| 1804 | 1809 |
| 1805 | 1810 |
| 1806 class _TokenPair { | 1811 class _TokenPair { |
| 1807 final _TokenDifferenceKind kind; | 1812 final _TokenDifferenceKind kind; |
| 1808 final Token oldToken; | 1813 final Token oldToken; |
| 1809 final Token newToken; | 1814 final Token newToken; |
| 1810 _TokenPair(this.kind, this.oldToken, this.newToken); | 1815 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1811 } | 1816 } |
| OLD | NEW |