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

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

Issue 1522583005: Issue 25238. Update LoclaElement(s) visible ranges during incremental resolution. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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 analyzer.src.generated.incremental_resolver; 5 library analyzer.src.generated.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/context/cache.dart'; 10 import 'package:analyzer/src/context/cache.dart';
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1110
1111 /** 1111 /**
1112 * Return `true` if the given node can be resolved independently of any other 1112 * Return `true` if the given node can be resolved independently of any other
1113 * nodes. 1113 * nodes.
1114 * 1114 *
1115 * *Note*: This method needs to be kept in sync with 1115 * *Note*: This method needs to be kept in sync with
1116 * [ScopeBuilder.ContextBuilder]. 1116 * [ScopeBuilder.ContextBuilder].
1117 * 1117 *
1118 * [node] - the node being tested. 1118 * [node] - the node being tested.
1119 */ 1119 */
1120 bool _canBeResolved(AstNode node) => node is ClassDeclaration || 1120 bool _canBeResolved(AstNode node) =>
1121 node is ClassDeclaration ||
1121 node is ClassTypeAlias || 1122 node is ClassTypeAlias ||
1122 node is CompilationUnit || 1123 node is CompilationUnit ||
1123 node is ConstructorDeclaration || 1124 node is ConstructorDeclaration ||
1124 node is FunctionDeclaration || 1125 node is FunctionDeclaration ||
1125 node is FunctionTypeAlias || 1126 node is FunctionTypeAlias ||
1126 node is MethodDeclaration || 1127 node is MethodDeclaration ||
1127 node is TopLevelVariableDeclaration; 1128 node is TopLevelVariableDeclaration;
1128 1129
1129 /** 1130 /**
1130 * Compute a value for all of the constants in the given [node]. 1131 * Compute a value for all of the constants in the given [node].
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 } finally { 1263 } finally {
1263 timer.stop('invalidate cache with delta'); 1264 timer.stop('invalidate cache with delta');
1264 } 1265 }
1265 } 1266 }
1266 } 1267 }
1267 1268
1268 void _updateElementNameOffsets() { 1269 void _updateElementNameOffsets() {
1269 LoggingTimer timer = logger.startTimer(); 1270 LoggingTimer timer = logger.startTimer();
1270 try { 1271 try {
1271 _definingUnit 1272 _definingUnit
1272 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); 1273 .accept(new _ElementOffsetUpdater(_updateOffset, _updateDelta));
1273 _definingUnit.afterIncrementalResolution(); 1274 _definingUnit.afterIncrementalResolution();
1274 } finally { 1275 } finally {
1275 timer.stop('update element offsets'); 1276 timer.stop('update element offsets');
1276 } 1277 }
1277 } 1278 }
1278 1279
1279 void _updateEntry() { 1280 void _updateEntry() {
1280 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []); 1281 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []);
1281 _updateErrors_NEW(RESOLVE_UNIT_ERRORS, _resolveErrors); 1282 _updateErrors_NEW(RESOLVE_UNIT_ERRORS, _resolveErrors);
1282 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []); 1283 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []);
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 } 1981 }
1981 } 1982 }
1982 1983
1983 /** 1984 /**
1984 * Instances of the class [_DeclarationMismatchException] represent an exception 1985 * Instances of the class [_DeclarationMismatchException] represent an exception
1985 * that is thrown when the element model defined by a given AST structure does 1986 * that is thrown when the element model defined by a given AST structure does
1986 * not match an existing element model. 1987 * not match an existing element model.
1987 */ 1988 */
1988 class _DeclarationMismatchException {} 1989 class _DeclarationMismatchException {}
1989 1990
1990 class _ElementNameOffsetUpdater extends GeneralizingElementVisitor { 1991 class _ElementOffsetUpdater extends GeneralizingElementVisitor {
1991 final int updateOffset; 1992 final int updateOffset;
1992 final int updateDelta; 1993 final int updateDelta;
1993 1994
1994 _ElementNameOffsetUpdater(this.updateOffset, this.updateDelta); 1995 _ElementOffsetUpdater(this.updateOffset, this.updateDelta);
1995 1996
1996 @override 1997 @override
1997 visitElement(Element element) { 1998 visitElement(Element element) {
1999 // name offset
1998 int nameOffset = element.nameOffset; 2000 int nameOffset = element.nameOffset;
1999 if (nameOffset > updateOffset) { 2001 if (nameOffset > updateOffset) {
2000 (element as ElementImpl).nameOffset = nameOffset + updateDelta; 2002 (element as ElementImpl).nameOffset = nameOffset + updateDelta;
2001 } 2003 }
2004 // visible range
2005 if (element is LocalElement) {
2006 SourceRange visibleRange = element.visibleRange;
2007 if (visibleRange != null && visibleRange.offset > updateOffset) {
2008 int newOffset = visibleRange.offset + updateDelta;
2009 int length = visibleRange.length;
2010 if (element is FunctionElementImpl) {
Brian Wilkerson 2015/12/12 15:31:56 I want to make a couple of changes to the element
2011 element.setVisibleRange(newOffset, length);
2012 } else if (element is LocalVariableElementImpl) {
2013 element.setVisibleRange(newOffset, length);
2014 } else if (element is ParameterElementImpl) {
2015 element.setVisibleRange(newOffset, length);
2016 }
2017 }
2018 }
2002 super.visitElement(element); 2019 super.visitElement(element);
2003 } 2020 }
2004 } 2021 }
2005 2022
2006 class _ElementsGatherer extends GeneralizingElementVisitor { 2023 class _ElementsGatherer extends GeneralizingElementVisitor {
2007 final DeclarationMatcher matcher; 2024 final DeclarationMatcher matcher;
2008 2025
2009 _ElementsGatherer(this.matcher); 2026 _ElementsGatherer(this.matcher);
2010 2027
2011 void addElements(List<Element> elements) { 2028 void addElements(List<Element> elements) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 @override 2090 @override
2074 String toString() => name; 2091 String toString() => name;
2075 } 2092 }
2076 2093
2077 class _TokenPair { 2094 class _TokenPair {
2078 final _TokenDifferenceKind kind; 2095 final _TokenDifferenceKind kind;
2079 final Token oldToken; 2096 final Token oldToken;
2080 final Token newToken; 2097 final Token newToken;
2081 _TokenPair(this.kind, this.oldToken, this.newToken); 2098 _TokenPair(this.kind, this.oldToken, this.newToken);
2082 } 2099 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698