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

Unified Diff: pkg/analyzer/lib/src/generated/incremental_resolver.dart

Issue 756453002: Incremental resolution: rename function/constructor/method parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/incremental_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index cb315f54e8ca6e8560f169c8f5d2a22814d5a7f7..a9bd08120eead99ce5546b9edd130dce8fc8050d 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -147,6 +147,7 @@ class DeclarationMatcher extends RecursiveAstVisitor {
_enclosingClass.unnamedConstructor :
_enclosingClass.getNamedConstructor(constructorName.name);
_processElement(element);
+ node.element = element;
_assertCompatibleParameters(node.parameters, element.parameters);
}
@@ -206,6 +207,8 @@ class DeclarationMatcher extends RecursiveAstVisitor {
if (property == null) {
element = _findElement(_enclosingUnit.functions, name);
_processElement(element);
+ node.name.staticElement = element;
+ node.functionExpression.element = element;
} else {
PropertyAccessorElement accessor =
_findElement(_enclosingUnit.accessors, name);
@@ -289,6 +292,7 @@ class DeclarationMatcher extends RecursiveAstVisitor {
}
// process element
_processElement(element);
+ node.name.staticElement = element;
// TODO(scheglov) test returnType
_assertSameType(node.returnType, element.returnType);
_assertCompatibleParameters(node.parameters, element.parameters);
@@ -392,6 +396,9 @@ class DeclarationMatcher extends RecursiveAstVisitor {
ParameterElement element) {
if (node is SimpleFormalParameter) {
_assertSameType(node.type, element.type);
+ node.identifier.staticElement = element;
+ element.nameOffset = node.identifier.offset;
+ (element as ElementImpl).name = node.identifier.name;
} else {
// TODO(scheglov) support other parameter types
_assertTrue(false);
@@ -661,10 +668,10 @@ class IncrementalResolver {
new _ElementNameOffsetUpdater(
_updateOffset,
_updateNewLength - _updateOldLength));
- _updateElements(rootNode);
if (_elementModelChanged(rootNode)) {
throw new AnalysisException("Cannot resolve node: element model changed");
}
+ _updateElements(rootNode);
// resolve root in scope
ResolutionContext context =
ResolutionContextBuilder.contextFor(rootNode, _errorListener);
@@ -702,6 +709,12 @@ class IncrementalResolver {
* be determined.
*/
bool _elementModelChanged(AstNode node) {
+ // If we are replacing the whole declaration (e.g. rename a parameter), we
+ // can try to find the corresponding Element in the enclosing one, see if it
+ // is compatible, and if 'yes', then restore and update it.
+ if (node is Declaration) {
+ node = node.parent;
+ }
Element element = _getElement(node);
if (element == null) {
throw new AnalysisException(
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698