| 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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 node is MethodDeclaration || | 1098 node is MethodDeclaration || |
| 1099 node is TopLevelVariableDeclaration; | 1099 node is TopLevelVariableDeclaration; |
| 1100 | 1100 |
| 1101 /** | 1101 /** |
| 1102 * 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]. |
| 1103 */ | 1103 */ |
| 1104 void _computeConstants(AstNode node) { | 1104 void _computeConstants(AstNode node) { |
| 1105 // compute values | 1105 // compute values |
| 1106 { | 1106 { |
| 1107 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); | 1107 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); |
| 1108 ConstantValueComputer computer = new ConstantValueComputer( | 1108 ConstantValueComputer computer = new ConstantValueComputer(_context, |
| 1109 _context, _typeProvider, _typeSystem, _context.declaredVariables); | 1109 _typeProvider, _context.declaredVariables, null, _typeSystem); |
| 1110 computer.add(unit, _source, _librarySource); | 1110 computer.add(unit, _source, _librarySource); |
| 1111 computer.computeValues(); | 1111 computer.computeValues(); |
| 1112 } | 1112 } |
| 1113 // validate | 1113 // validate |
| 1114 { | 1114 { |
| 1115 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1115 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1116 ConstantVerifier constantVerifier = new ConstantVerifier( | 1116 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, |
| 1117 errorReporter, | 1117 _definingLibrary, _typeProvider, _context.declaredVariables); |
| 1118 _definingLibrary, | |
| 1119 _typeProvider, | |
| 1120 _typeSystem, | |
| 1121 _context.declaredVariables); | |
| 1122 node.accept(constantVerifier); | 1118 node.accept(constantVerifier); |
| 1123 } | 1119 } |
| 1124 } | 1120 } |
| 1125 | 1121 |
| 1126 /** | 1122 /** |
| 1127 * Starting at [node], find the smallest AST node that can be resolved | 1123 * Starting at [node], find the smallest AST node that can be resolved |
| 1128 * independently of any other nodes. Return the node that was found. | 1124 * independently of any other nodes. Return the node that was found. |
| 1129 * | 1125 * |
| 1130 * [node] - the node at which the search is to begin | 1126 * [node] - the node at which the search is to begin |
| 1131 * | 1127 * |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 } | 1171 } |
| 1176 // resolve variables | 1172 // resolve variables |
| 1177 { | 1173 { |
| 1178 VariableResolverVisitor visitor = new VariableResolverVisitor( | 1174 VariableResolverVisitor visitor = new VariableResolverVisitor( |
| 1179 _definingLibrary, _source, _typeProvider, errorListener, | 1175 _definingLibrary, _source, _typeProvider, errorListener, |
| 1180 nameScope: scope); | 1176 nameScope: scope); |
| 1181 node.accept(visitor); | 1177 node.accept(visitor); |
| 1182 } | 1178 } |
| 1183 // resolve references | 1179 // resolve references |
| 1184 { | 1180 { |
| 1185 ResolverVisitor visitor = new ResolverVisitor(_definingLibrary, _source, | 1181 ResolverVisitor visitor = new ResolverVisitor( |
| 1186 _typeProvider, _typeSystem, errorListener, | 1182 _definingLibrary, _source, _typeProvider, errorListener, |
| 1187 nameScope: scope); | 1183 nameScope: scope); |
| 1188 if (_resolutionContext.enclosingClassDeclaration != null) { | 1184 if (_resolutionContext.enclosingClassDeclaration != null) { |
| 1189 visitor.visitClassDeclarationIncrementally( | 1185 visitor.visitClassDeclarationIncrementally( |
| 1190 _resolutionContext.enclosingClassDeclaration); | 1186 _resolutionContext.enclosingClassDeclaration); |
| 1191 } | 1187 } |
| 1192 if (node is Comment) { | 1188 if (node is Comment) { |
| 1193 visitor.resolveOnlyCommentInFunctionBody = true; | 1189 visitor.resolveOnlyCommentInFunctionBody = true; |
| 1194 node = node.parent; | 1190 node = node.parent; |
| 1195 } | 1191 } |
| 1196 visitor.initForIncrementalResolution(); | 1192 visitor.initForIncrementalResolution(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 | 1331 |
| 1336 void _verify(AstNode node) { | 1332 void _verify(AstNode node) { |
| 1337 LoggingTimer timer = logger.startTimer(); | 1333 LoggingTimer timer = logger.startTimer(); |
| 1338 try { | 1334 try { |
| 1339 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1335 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1340 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1336 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1341 ErrorVerifier errorVerifier = new ErrorVerifier( | 1337 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 1342 errorReporter, | 1338 errorReporter, |
| 1343 _definingLibrary, | 1339 _definingLibrary, |
| 1344 _typeProvider, | 1340 _typeProvider, |
| 1345 _typeSystem, | |
| 1346 new InheritanceManager(_definingLibrary), | 1341 new InheritanceManager(_definingLibrary), |
| 1347 _context.analysisOptions.enableSuperMixins); | 1342 _context.analysisOptions.enableSuperMixins); |
| 1348 if (_resolutionContext.enclosingClassDeclaration != null) { | 1343 if (_resolutionContext.enclosingClassDeclaration != null) { |
| 1349 errorVerifier.visitClassDeclarationIncrementally( | 1344 errorVerifier.visitClassDeclarationIncrementally( |
| 1350 _resolutionContext.enclosingClassDeclaration); | 1345 _resolutionContext.enclosingClassDeclaration); |
| 1351 } | 1346 } |
| 1352 node.accept(errorVerifier); | 1347 node.accept(errorVerifier); |
| 1353 _verifyErrors = errorListener.getErrorsForSource(_source); | 1348 _verifyErrors = errorListener.getErrorsForSource(_source); |
| 1354 } finally { | 1349 } finally { |
| 1355 timer.stop('verify'); | 1350 timer.stop('verify'); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 @override | 2115 @override |
| 2121 String toString() => name; | 2116 String toString() => name; |
| 2122 } | 2117 } |
| 2123 | 2118 |
| 2124 class _TokenPair { | 2119 class _TokenPair { |
| 2125 final _TokenDifferenceKind kind; | 2120 final _TokenDifferenceKind kind; |
| 2126 final Token oldToken; | 2121 final Token oldToken; |
| 2127 final Token newToken; | 2122 final Token newToken; |
| 2128 _TokenPair(this.kind, this.oldToken, this.newToken); | 2123 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 2129 } | 2124 } |
| OLD | NEW |