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

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

Issue 770613003: Don't throw an exception when model is changed. (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 'ast.dart'; 10 import 'ast.dart';
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 IncrementalResolver(this._typeProvider, this._definingUnit, 664 IncrementalResolver(this._typeProvider, this._definingUnit,
665 this._updateOffset, this._updateOldLength, this._updateNewLength) { 665 this._updateOffset, this._updateOldLength, this._updateNewLength) {
666 _definingLibrary = _definingUnit.library; 666 _definingLibrary = _definingUnit.library;
667 _source = _definingUnit.source; 667 _source = _definingUnit.source;
668 } 668 }
669 669
670 /** 670 /**
671 * Resolve [node], reporting any errors or warnings to the given listener. 671 * Resolve [node], reporting any errors or warnings to the given listener.
672 * 672 *
673 * [node] - the root of the AST structure to be resolved. 673 * [node] - the root of the AST structure to be resolved.
674 *
675 * Returns `true` if resolution was successful.
674 */ 676 */
675 void resolve(AstNode node) { 677 bool resolve(AstNode node) {
676 logger.enter('resolve: $_definingUnit'); 678 logger.enter('resolve: $_definingUnit');
677 try { 679 try {
678 logger.log(() => 'node: $node'); 680 logger.log(() => 'node: $node');
679 AstNode rootNode = _findResolutionRoot(node); 681 AstNode rootNode = _findResolutionRoot(node);
680 logger.log(() => 'rootNode: $rootNode'); 682 logger.log(() => 'rootNode: $rootNode');
681 // update elements 683 // update elements
682 _updateElementNameOffsets( 684 _updateElementNameOffsets(
683 _definingUnit, 685 _definingUnit,
684 _updateOffset, 686 _updateOffset,
685 _updateNewLength - _updateOldLength); 687 _updateNewLength - _updateOldLength);
686 if (_elementModelChanged(rootNode)) { 688 if (_elementModelChanged(rootNode)) {
687 throw new AnalysisException( 689 return false;
688 "Cannot resolve node: element model changed");
689 } 690 }
690 _updateElements(rootNode); 691 _updateElements(rootNode);
691 // resolve 692 // resolve
692 _resolveReferences(rootNode); 693 _resolveReferences(rootNode);
693 // verify 694 // verify
694 _verify(rootNode); 695 _verify(rootNode);
695 _generateHints(rootNode); 696 _generateHints(rootNode);
697 // OK
698 return true;
696 } finally { 699 } finally {
697 logger.exit(); 700 logger.exit();
698 } 701 }
699 } 702 }
700 703
701 /** 704 /**
702 * Return `true` if the given node can be resolved independently of any other 705 * Return `true` if the given node can be resolved independently of any other
703 * nodes. 706 * nodes.
704 * 707 *
705 * *Note*: This method needs to be kept in sync with 708 * *Note*: This method needs to be kept in sync with
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 _shiftTokens(oldNode.endToken.next); 1060 _shiftTokens(oldNode.endToken.next);
1058 } 1061 }
1059 // perform incremental resolution 1062 // perform incremental resolution
1060 CompilationUnitElement oldUnitElement = oldUnit.element; 1063 CompilationUnitElement oldUnitElement = oldUnit.element;
1061 IncrementalResolver incrementalResolver = new IncrementalResolver( 1064 IncrementalResolver incrementalResolver = new IncrementalResolver(
1062 _typeProvider, 1065 _typeProvider,
1063 oldUnitElement, 1066 oldUnitElement,
1064 _updateOffset, 1067 _updateOffset,
1065 oldNode.length, 1068 oldNode.length,
1066 newNode.length); 1069 newNode.length);
1067 incrementalResolver.resolve(newNode); 1070 bool success = incrementalResolver.resolve(newNode);
1071 // check if success
1072 if (!success) {
1073 logger.log('Failure: element model changed.');
1074 return false;
1075 }
1076 // update DartEntry
1068 _newResolveErrors = incrementalResolver._resolveErrors; 1077 _newResolveErrors = incrementalResolver._resolveErrors;
1069 _newVerifyErrors = incrementalResolver._verifyErrors; 1078 _newVerifyErrors = incrementalResolver._verifyErrors;
1070 _newHints = incrementalResolver._hints; 1079 _newHints = incrementalResolver._hints;
1071 _updateEntry(); 1080 _updateEntry();
1072 logger.log('Success.'); 1081 logger.log('Success.');
1073 return true; 1082 return true;
1074 } 1083 }
1075 } catch (e, st) { 1084 } catch (e, st) {
1076 logger.log(e); 1085 logger.log(e);
1077 logger.log(st); 1086 logger.log(st);
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 String toString() => name; 1656 String toString() => name;
1648 } 1657 }
1649 1658
1650 1659
1651 class _TokenPair { 1660 class _TokenPair {
1652 final _TokenDifferenceKind kind; 1661 final _TokenDifferenceKind kind;
1653 final Token oldToken; 1662 final Token oldToken;
1654 final Token newToken; 1663 final Token newToken;
1655 _TokenPair(this.kind, this.oldToken, this.newToken); 1664 _TokenPair(this.kind, this.oldToken, this.newToken);
1656 } 1665 }
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