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

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

Issue 759353002: Fix for incremental resolution of top-level and class-member accessors. (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/test/generated/incremental_resolver_test.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 'package:analyzer/src/generated/error_verifier.dart'; 10 import 'package:analyzer/src/generated/error_verifier.dart';
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 _ElementsRestorer elementsRestorer = new _ElementsRestorer(node); 811 _ElementsRestorer elementsRestorer = new _ElementsRestorer(node);
812 try { 812 try {
813 holder = new ElementHolder(); 813 holder = new ElementHolder();
814 ElementBuilder builder = new ElementBuilder(holder); 814 ElementBuilder builder = new ElementBuilder(holder);
815 node.accept(builder); 815 node.accept(builder);
816 } finally { 816 } finally {
817 elementsRestorer.restore(); 817 elementsRestorer.restore();
818 } 818 }
819 // apply compatible changes to elements 819 // apply compatible changes to elements
820 if (node is FunctionDeclaration) { 820 if (node is FunctionDeclaration) {
821 FunctionElementImpl oldElement = node.element; 821 ExecutableElementImpl oldElement = node.element;
822 FunctionElementImpl newElement = holder.functions[0]; 822 // prepare the new element
823 ExecutableElement newElement;
824 {
825 List<FunctionElement> holderFunctions = holder.functions;
826 List<PropertyAccessorElement> holderAccessors = holder.accessors;
827 if (holderFunctions.isNotEmpty) {
828 newElement = holderFunctions[0];
829 } else if (holderAccessors.isNotEmpty) {
830 newElement = holderAccessors[0];
831 }
832 }
833 // update the old Element
823 oldElement.labels = newElement.labels; 834 oldElement.labels = newElement.labels;
824 oldElement.localVariables = newElement.localVariables; 835 oldElement.localVariables = newElement.localVariables;
825 } 836 }
826 if (node is MethodDeclaration) { 837 if (node is MethodDeclaration) {
827 MethodElementImpl oldElement = node.element; 838 ExecutableElementImpl oldElement = node.element;
828 MethodElementImpl newElement = holder.methods[0]; 839 // prepare the new element
840 ExecutableElement newElement;
841 {
842 List<MethodElement> holderMethods = holder.methods;
843 List<PropertyAccessorElement> holderAccessors = holder.accessors;
844 if (holderMethods.isNotEmpty) {
845 newElement = holderMethods[0];
846 } else if (holderAccessors.isNotEmpty) {
847 newElement = holderAccessors[0];
848 }
849 }
850 // update the old Element
829 oldElement.labels = newElement.labels; 851 oldElement.labels = newElement.labels;
830 oldElement.localVariables = newElement.localVariables; 852 oldElement.localVariables = newElement.localVariables;
831 } 853 }
832 } 854 }
833 855
834 void _verify(AstNode node) { 856 void _verify(AstNode node) {
835 RecordingErrorListener errorListener = new RecordingErrorListener(); 857 RecordingErrorListener errorListener = new RecordingErrorListener();
836 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 858 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
837 ErrorVerifier errorVerifier = new ErrorVerifier( 859 ErrorVerifier errorVerifier = new ErrorVerifier(
838 errorReporter, 860 errorReporter,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 oldUnitElement, 977 oldUnitElement,
956 oldUnitElement.source, 978 oldUnitElement.source,
957 _updateOffset, 979 _updateOffset,
958 oldNode.length, 980 oldNode.length,
959 newNode.length); 981 newNode.length);
960 incrementalResolver.resolve(newNode); 982 incrementalResolver.resolve(newNode);
961 _newResolveErrors = incrementalResolver._resolveErrors; 983 _newResolveErrors = incrementalResolver._resolveErrors;
962 _newVerifyErrors = incrementalResolver._verifyErrors; 984 _newVerifyErrors = incrementalResolver._verifyErrors;
963 _newHints = incrementalResolver._hints; 985 _newHints = incrementalResolver._hints;
964 _updateEntry(); 986 _updateEntry();
987 print('Successfully incrementally resolved.');
Brian Wilkerson 2014/11/26 19:41:27 Comment this out?
965 return true; 988 return true;
966 } 989 }
967 } catch (e, st) { 990 } catch (e, st) {
968 // TODO(scheglov) find a way to log these exceptions 991 // TODO(scheglov) find a way to log these exceptions
969 print(e); 992 print(e);
970 print(st); 993 print(st);
971 } 994 }
972 return false; 995 return false;
973 } 996 }
974 997
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 _elements[node] = node.staticElement; 1427 _elements[node] = node.staticElement;
1405 } 1428 }
1406 } 1429 }
1407 1430
1408 1431
1409 class _TokenPair { 1432 class _TokenPair {
1410 final Token oldToken; 1433 final Token oldToken;
1411 final Token newToken; 1434 final Token newToken;
1412 _TokenPair(this.oldToken, this.newToken); 1435 _TokenPair(this.oldToken, this.newToken);
1413 } 1436 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698