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

Side by Side Diff: pkg/analyzer/lib/src/generated/incremental_resolver.dart

Issue 799993002: Issue 21850. Fix for incremental resolving field formal parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 SimpleIdentifier constructorName = node.name; 182 SimpleIdentifier constructorName = node.name;
183 ConstructorElementImpl element = constructorName == null ? 183 ConstructorElementImpl element = constructorName == null ?
184 _enclosingClass.unnamedConstructor : 184 _enclosingClass.unnamedConstructor :
185 _enclosingClass.getNamedConstructor(constructorName.name); 185 _enclosingClass.getNamedConstructor(constructorName.name);
186 _processElement(element); 186 _processElement(element);
187 _assertCompatibleParameters(node.parameters, element.parameters); 187 _assertCompatibleParameters(node.parameters, element.parameters);
188 // matches, update the existing element 188 // matches, update the existing element
189 ExecutableElement newElement = node.element; 189 ExecutableElement newElement = node.element;
190 node.element = element; 190 node.element = element;
191 _setLocalElements(element, newElement); 191 _setLocalElements(element, newElement);
192 _setParameterElements(node.parameters, element.parameters);
193 } 192 }
194 193
195 @override 194 @override
196 visitEnumConstantDeclaration(EnumConstantDeclaration node) { 195 visitEnumConstantDeclaration(EnumConstantDeclaration node) {
197 String name = node.name.name; 196 String name = node.name.name;
198 FieldElement element = _findElement(_enclosingClass.fields, name); 197 FieldElement element = _findElement(_enclosingClass.fields, name);
199 _processElement(element); 198 _processElement(element);
200 } 199 }
201 200
202 @override 201 @override
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 _assertFalse(element.isSynthetic); 259 _assertFalse(element.isSynthetic);
261 _assertSameType(node.returnType, element.returnType); 260 _assertSameType(node.returnType, element.returnType);
262 _assertCompatibleParameters( 261 _assertCompatibleParameters(
263 node.functionExpression.parameters, 262 node.functionExpression.parameters,
264 element.parameters); 263 element.parameters);
265 // matches, update the existing element 264 // matches, update the existing element
266 ExecutableElement newElement = node.element; 265 ExecutableElement newElement = node.element;
267 node.name.staticElement = element; 266 node.name.staticElement = element;
268 node.functionExpression.element = element; 267 node.functionExpression.element = element;
269 _setLocalElements(element, newElement); 268 _setLocalElements(element, newElement);
270 _setParameterElements(
271 node.functionExpression.parameters,
272 element.parameters);
273 } 269 }
274 270
275 @override 271 @override
276 visitFunctionTypeAlias(FunctionTypeAlias node) { 272 visitFunctionTypeAlias(FunctionTypeAlias node) {
277 String name = node.name.name; 273 String name = node.name.name;
278 FunctionTypeAliasElement element = 274 FunctionTypeAliasElement element =
279 _findElement(_enclosingUnit.functionTypeAliases, name); 275 _findElement(_enclosingUnit.functionTypeAliases, name);
280 _processElement(element); 276 _processElement(element);
281 _assertSameTypeParameters(node.typeParameters, element.typeParameters); 277 _assertSameTypeParameters(node.typeParameters, element.typeParameters);
282 _assertSameType(node.returnType, element.returnType); 278 _assertSameType(node.returnType, element.returnType);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 ExecutableElement newElement = node.element; 330 ExecutableElement newElement = node.element;
335 try { 331 try {
336 _assertNotNull(element); 332 _assertNotNull(element);
337 _assertEquals(node.isStatic, element.isStatic); 333 _assertEquals(node.isStatic, element.isStatic);
338 _assertSameType(node.returnType, element.returnType); 334 _assertSameType(node.returnType, element.returnType);
339 _assertCompatibleParameters(node.parameters, element.parameters); 335 _assertCompatibleParameters(node.parameters, element.parameters);
340 _removedElements.remove(element); 336 _removedElements.remove(element);
341 // matches, update the existing element 337 // matches, update the existing element
342 node.name.staticElement = element; 338 node.name.staticElement = element;
343 _setLocalElements(element, newElement); 339 _setLocalElements(element, newElement);
344 _setParameterElements(node.parameters, element.parameters);
345 } on _DeclarationMismatchException catch (e) { 340 } on _DeclarationMismatchException catch (e) {
346 _addedElements.add(newElement); 341 _addedElements.add(newElement);
347 // remove old element 342 // remove old element
348 if (element is MethodElement) { 343 if (element is MethodElement) {
349 _enclosingClass.methods.remove(element); 344 _enclosingClass.methods.remove(element);
350 } else if (element is PropertyAccessorElement) { 345 } else if (element is PropertyAccessorElement) {
351 _enclosingClass.accessors.remove(element); 346 _enclosingClass.accessors.remove(element);
352 } 347 }
353 // add new element 348 // add new element
354 if (newElement is MethodElement) { 349 if (newElement is MethodElement) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 return null; 662 return null;
668 } 663 }
669 return literal.stringValue; 664 return literal.stringValue;
670 } 665 }
671 666
672 static void _setLocalElements(ExecutableElementImpl to, 667 static void _setLocalElements(ExecutableElementImpl to,
673 ExecutableElement from) { 668 ExecutableElement from) {
674 to.functions = from.functions; 669 to.functions = from.functions;
675 to.labels = from.labels; 670 to.labels = from.labels;
676 to.localVariables = from.localVariables; 671 to.localVariables = from.localVariables;
677 } 672 to.parameters = from.parameters;
678
679 static void _setParameterElements(FormalParameterList nodes,
680 List<ParameterElement> elements) {
681 if (nodes != null) {
682 for (int i = 0; i < elements.length; i++) {
683 ParameterElement element = elements[i];
684 FormalParameter node = nodes.parameters[i];
685 ParameterElement newElement = node.element;
686 node.identifier.staticElement = element;
687 (element as ElementImpl).name = newElement.name;
688 (element as ElementImpl).nameOffset = newElement.nameOffset;
689 if (node is FunctionTypedFormalParameter) {
690 _setParameterElements(node.parameters, element.parameters);
691 }
692 }
693 }
694 } 673 }
695 } 674 }
696 675
697 676
698 /** 677 /**
699 * Describes how declarations match an existing elements model. 678 * Describes how declarations match an existing elements model.
700 */ 679 */
701 class DeclarationMatchKind { 680 class DeclarationMatchKind {
702 /** 681 /**
703 * Complete match, no API changes. 682 * Complete match, no API changes.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } finally { 799 } finally {
821 logger.exit(); 800 logger.exit();
822 } 801 }
823 } 802 }
824 803
825 void _buildElements(AstNode node) { 804 void _buildElements(AstNode node) {
826 LoggingTimer timer = logger.startTimer(); 805 LoggingTimer timer = logger.startTimer();
827 try { 806 try {
828 ElementHolder holder = new ElementHolder(); 807 ElementHolder holder = new ElementHolder();
829 ElementBuilder builder = new ElementBuilder(holder); 808 ElementBuilder builder = new ElementBuilder(holder);
809 if (_resolutionContext.enclosingClassDeclaration != null) {
810 builder.visitClassDeclarationIncrementally(
811 _resolutionContext.enclosingClassDeclaration);
812 }
830 node.accept(builder); 813 node.accept(builder);
831 } finally { 814 } finally {
832 timer.stop('build elements'); 815 timer.stop('build elements');
833 } 816 }
834 } 817 }
835 818
836 /** 819 /**
837 * Return `true` if [node] does not have element model changes, or these 820 * Return `true` if [node] does not have element model changes, or these
838 * changes can be incrementally propagated. 821 * changes can be incrementally propagated.
839 */ 822 */
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 String toString() => name; 1713 String toString() => name;
1731 } 1714 }
1732 1715
1733 1716
1734 class _TokenPair { 1717 class _TokenPair {
1735 final _TokenDifferenceKind kind; 1718 final _TokenDifferenceKind kind;
1736 final Token oldToken; 1719 final Token oldToken;
1737 final Token newToken; 1720 final Token newToken;
1738 _TokenPair(this.kind, this.oldToken, this.newToken); 1721 _TokenPair(this.kind, this.oldToken, this.newToken);
1739 } 1722 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698