| OLD | NEW |
| 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/context/cache.dart' | 10 import 'package:analyzer/src/context/cache.dart' |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 * The context the compilation unit being resolved in. | 907 * The context the compilation unit being resolved in. |
| 908 */ | 908 */ |
| 909 AnalysisContext _context; | 909 AnalysisContext _context; |
| 910 | 910 |
| 911 /** | 911 /** |
| 912 * The object used to access the types from the core library. | 912 * The object used to access the types from the core library. |
| 913 */ | 913 */ |
| 914 TypeProvider _typeProvider; | 914 TypeProvider _typeProvider; |
| 915 | 915 |
| 916 /** | 916 /** |
| 917 * The type system primitives. |
| 918 */ |
| 919 TypeSystem _typeSystem; |
| 920 |
| 921 /** |
| 917 * The element for the library containing the compilation unit being resolved. | 922 * The element for the library containing the compilation unit being resolved. |
| 918 */ | 923 */ |
| 919 LibraryElementImpl _definingLibrary; | 924 LibraryElementImpl _definingLibrary; |
| 920 | 925 |
| 921 /** | 926 /** |
| 922 * The [DartEntry] corresponding to the source being resolved. | 927 * The [DartEntry] corresponding to the source being resolved. |
| 923 */ | 928 */ |
| 924 DartEntry oldEntry; | 929 DartEntry oldEntry; |
| 925 | 930 |
| 926 /** | 931 /** |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 this._definingUnit, | 990 this._definingUnit, |
| 986 this._updateOffset, | 991 this._updateOffset, |
| 987 this._updateEndOld, | 992 this._updateEndOld, |
| 988 this._updateEndNew) { | 993 this._updateEndNew) { |
| 989 _updateDelta = _updateEndNew - _updateEndOld; | 994 _updateDelta = _updateEndNew - _updateEndOld; |
| 990 _definingLibrary = _definingUnit.library; | 995 _definingLibrary = _definingUnit.library; |
| 991 _librarySource = _definingLibrary.source; | 996 _librarySource = _definingLibrary.source; |
| 992 _source = _definingUnit.source; | 997 _source = _definingUnit.source; |
| 993 _context = _definingUnit.context; | 998 _context = _definingUnit.context; |
| 994 _typeProvider = _context.typeProvider; | 999 _typeProvider = _context.typeProvider; |
| 1000 _typeSystem = _context.typeSystem; |
| 995 } | 1001 } |
| 996 | 1002 |
| 997 /** | 1003 /** |
| 998 * Resolve [node], reporting any errors or warnings to the given listener. | 1004 * Resolve [node], reporting any errors or warnings to the given listener. |
| 999 * | 1005 * |
| 1000 * [node] - the root of the AST structure to be resolved. | 1006 * [node] - the root of the AST structure to be resolved. |
| 1001 * | 1007 * |
| 1002 * Returns `true` if resolution was successful. | 1008 * Returns `true` if resolution was successful. |
| 1003 */ | 1009 */ |
| 1004 bool resolve(AstNode node) { | 1010 bool resolve(AstNode node) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 node is TopLevelVariableDeclaration; | 1099 node is TopLevelVariableDeclaration; |
| 1094 | 1100 |
| 1095 /** | 1101 /** |
| 1096 * Compute a value for all of the constants in the given [node]. | 1102 * Compute a value for all of the constants in the given [node]. |
| 1097 */ | 1103 */ |
| 1098 void _computeConstants(AstNode node) { | 1104 void _computeConstants(AstNode node) { |
| 1099 // compute values | 1105 // compute values |
| 1100 { | 1106 { |
| 1101 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); | 1107 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); |
| 1102 ConstantValueComputer computer = new ConstantValueComputer( | 1108 ConstantValueComputer computer = new ConstantValueComputer( |
| 1103 _context, _typeProvider, _context.declaredVariables); | 1109 _context, _typeProvider, _typeSystem, _context.declaredVariables); |
| 1104 computer.add(unit, _source, _librarySource); | 1110 computer.add(unit, _source, _librarySource); |
| 1105 computer.computeValues(); | 1111 computer.computeValues(); |
| 1106 } | 1112 } |
| 1107 // validate | 1113 // validate |
| 1108 { | 1114 { |
| 1109 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1115 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1110 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, | 1116 ConstantVerifier constantVerifier = new ConstantVerifier( |
| 1111 _definingLibrary, _typeProvider, _context.declaredVariables); | 1117 errorReporter, |
| 1118 _definingLibrary, |
| 1119 _typeProvider, |
| 1120 _typeSystem, |
| 1121 _context.declaredVariables); |
| 1112 node.accept(constantVerifier); | 1122 node.accept(constantVerifier); |
| 1113 } | 1123 } |
| 1114 } | 1124 } |
| 1115 | 1125 |
| 1116 /** | 1126 /** |
| 1117 * Starting at [node], find the smallest AST node that can be resolved | 1127 * Starting at [node], find the smallest AST node that can be resolved |
| 1118 * independently of any other nodes. Return the node that was found. | 1128 * independently of any other nodes. Return the node that was found. |
| 1119 * | 1129 * |
| 1120 * [node] - the node at which the search is to begin | 1130 * [node] - the node at which the search is to begin |
| 1121 * | 1131 * |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1175 } |
| 1166 // resolve variables | 1176 // resolve variables |
| 1167 { | 1177 { |
| 1168 VariableResolverVisitor visitor = new VariableResolverVisitor( | 1178 VariableResolverVisitor visitor = new VariableResolverVisitor( |
| 1169 _definingLibrary, _source, _typeProvider, errorListener, | 1179 _definingLibrary, _source, _typeProvider, errorListener, |
| 1170 nameScope: scope); | 1180 nameScope: scope); |
| 1171 node.accept(visitor); | 1181 node.accept(visitor); |
| 1172 } | 1182 } |
| 1173 // resolve references | 1183 // resolve references |
| 1174 { | 1184 { |
| 1175 ResolverVisitor visitor = new ResolverVisitor( | 1185 ResolverVisitor visitor = new ResolverVisitor(_definingLibrary, _source, |
| 1176 _definingLibrary, _source, _typeProvider, errorListener, | 1186 _typeProvider, _typeSystem, errorListener, |
| 1177 nameScope: scope); | 1187 nameScope: scope); |
| 1178 if (_resolutionContext.enclosingClassDeclaration != null) { | 1188 if (_resolutionContext.enclosingClassDeclaration != null) { |
| 1179 visitor.visitClassDeclarationIncrementally( | 1189 visitor.visitClassDeclarationIncrementally( |
| 1180 _resolutionContext.enclosingClassDeclaration); | 1190 _resolutionContext.enclosingClassDeclaration); |
| 1181 } | 1191 } |
| 1182 if (node is Comment) { | 1192 if (node is Comment) { |
| 1183 visitor.resolveOnlyCommentInFunctionBody = true; | 1193 visitor.resolveOnlyCommentInFunctionBody = true; |
| 1184 node = node.parent; | 1194 node = node.parent; |
| 1185 } | 1195 } |
| 1186 visitor.initForIncrementalResolution(); | 1196 visitor.initForIncrementalResolution(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 | 1335 |
| 1326 void _verify(AstNode node) { | 1336 void _verify(AstNode node) { |
| 1327 LoggingTimer timer = logger.startTimer(); | 1337 LoggingTimer timer = logger.startTimer(); |
| 1328 try { | 1338 try { |
| 1329 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1339 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1330 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1340 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1331 ErrorVerifier errorVerifier = new ErrorVerifier( | 1341 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 1332 errorReporter, | 1342 errorReporter, |
| 1333 _definingLibrary, | 1343 _definingLibrary, |
| 1334 _typeProvider, | 1344 _typeProvider, |
| 1345 _typeSystem, |
| 1335 new InheritanceManager(_definingLibrary), | 1346 new InheritanceManager(_definingLibrary), |
| 1336 _context.analysisOptions.enableSuperMixins); | 1347 _context.analysisOptions.enableSuperMixins); |
| 1337 if (_resolutionContext.enclosingClassDeclaration != null) { | 1348 if (_resolutionContext.enclosingClassDeclaration != null) { |
| 1338 errorVerifier.visitClassDeclarationIncrementally( | 1349 errorVerifier.visitClassDeclarationIncrementally( |
| 1339 _resolutionContext.enclosingClassDeclaration); | 1350 _resolutionContext.enclosingClassDeclaration); |
| 1340 } | 1351 } |
| 1341 node.accept(errorVerifier); | 1352 node.accept(errorVerifier); |
| 1342 _verifyErrors = errorListener.getErrorsForSource(_source); | 1353 _verifyErrors = errorListener.getErrorsForSource(_source); |
| 1343 } finally { | 1354 } finally { |
| 1344 timer.stop('verify'); | 1355 timer.stop('verify'); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 @override | 2120 @override |
| 2110 String toString() => name; | 2121 String toString() => name; |
| 2111 } | 2122 } |
| 2112 | 2123 |
| 2113 class _TokenPair { | 2124 class _TokenPair { |
| 2114 final _TokenDifferenceKind kind; | 2125 final _TokenDifferenceKind kind; |
| 2115 final Token oldToken; | 2126 final Token oldToken; |
| 2116 final Token newToken; | 2127 final Token newToken; |
| 2117 _TokenPair(this.kind, this.oldToken, this.newToken); | 2128 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 2118 } | 2129 } |
| OLD | NEW |