OLD | NEW |
1 import 'dart:io' as io; | 1 import 'dart:io' as io; |
2 | 2 |
3 import 'package:analyzer/dart/element/element.dart'; | 3 import 'package:analyzer/dart/element/element.dart'; |
4 import 'package:analyzer/file_system/file_system.dart'; | 4 import 'package:analyzer/file_system/file_system.dart'; |
5 import 'package:analyzer/src/context/cache.dart'; | 5 import 'package:analyzer/src/context/cache.dart'; |
6 import 'package:analyzer/src/context/context.dart'; | 6 import 'package:analyzer/src/context/context.dart'; |
7 import 'package:analyzer/src/dart/element/element.dart'; | 7 import 'package:analyzer/src/dart/element/element.dart'; |
8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
9 import 'package:analyzer/src/generated/java_io.dart'; | 9 import 'package:analyzer/src/generated/java_io.dart'; |
10 import 'package:analyzer/src/generated/resolver.dart'; | 10 import 'package:analyzer/src/generated/resolver.dart'; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void addBundle(String path, PackageBundle bundle) { | 167 void addBundle(String path, PackageBundle bundle) { |
168 _dataStore.addBundle(path, bundle); | 168 _dataStore.addBundle(path, bundle); |
169 } | 169 } |
170 | 170 |
171 @override | 171 @override |
172 bool compute(CacheEntry entry, ResultDescriptor result) { | 172 bool compute(CacheEntry entry, ResultDescriptor result) { |
173 if (_sdkProvider != null && _sdkProvider.compute(entry, result)) { | 173 if (_sdkProvider != null && _sdkProvider.compute(entry, result)) { |
174 return true; | 174 return true; |
175 } | 175 } |
176 AnalysisTarget target = entry.target; | 176 AnalysisTarget target = entry.target; |
| 177 |
| 178 // LINE_INFO can be provided using just the UnlinkedUnit. |
| 179 if (target is Source && result == LINE_INFO) { |
| 180 String uriString = target.uri.toString(); |
| 181 UnlinkedUnit unlinkedUnit = _dataStore.unlinkedMap[uriString]; |
| 182 if (unlinkedUnit != null) { |
| 183 List<int> lineStarts = unlinkedUnit.lineStarts; |
| 184 if (lineStarts.isNotEmpty) { |
| 185 LineInfo lineInfo = new LineInfo(lineStarts); |
| 186 entry.setValue(result as ResultDescriptor<LineInfo>, lineInfo, |
| 187 TargetedResult.EMPTY_LIST); |
| 188 return true; |
| 189 } |
| 190 } |
| 191 return false; |
| 192 } |
| 193 |
177 // Check whether there are results for the source. | 194 // Check whether there are results for the source. |
178 if (!hasResultsForSource(target.librarySource ?? target.source)) { | 195 if (!hasResultsForSource(target.librarySource ?? target.source)) { |
179 return false; | 196 return false; |
180 } | 197 } |
181 // Constant expressions are always resolved in summaries. | 198 // Constant expressions are always resolved in summaries. |
182 if (result == CONSTANT_EXPRESSION_RESOLVED && | 199 if (result == CONSTANT_EXPRESSION_RESOLVED && |
183 target is ConstantEvaluationTarget) { | 200 target is ConstantEvaluationTarget) { |
184 entry.setValue( | 201 entry.setValue( |
185 result as ResultDescriptor<bool>, true, TargetedResult.EMPTY_LIST); | 202 result as ResultDescriptor<bool>, true, TargetedResult.EMPTY_LIST); |
186 return true; | 203 return true; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (libraryUriStrings != null) { | 249 if (libraryUriStrings != null) { |
233 List<Source> librarySources = libraryUriStrings | 250 List<Source> librarySources = libraryUriStrings |
234 .map((libraryUriString) => | 251 .map((libraryUriString) => |
235 context.sourceFactory.resolveUri(target, libraryUriString)) | 252 context.sourceFactory.resolveUri(target, libraryUriString)) |
236 .toList(growable: false); | 253 .toList(growable: false); |
237 entry.setValue(result as ResultDescriptor<List<Source>>, | 254 entry.setValue(result as ResultDescriptor<List<Source>>, |
238 librarySources, TargetedResult.EMPTY_LIST); | 255 librarySources, TargetedResult.EMPTY_LIST); |
239 return true; | 256 return true; |
240 } | 257 } |
241 return false; | 258 return false; |
242 } else if (result == LINE_INFO) { | |
243 UnlinkedUnit unlinkedUnit = _dataStore.unlinkedMap[uriString]; | |
244 List<int> lineStarts = unlinkedUnit.lineStarts; | |
245 if (lineStarts.isNotEmpty) { | |
246 LineInfo lineInfo = new LineInfo(lineStarts); | |
247 entry.setValue(result as ResultDescriptor<LineInfo>, lineInfo, | |
248 TargetedResult.EMPTY_LIST); | |
249 return true; | |
250 } | |
251 return false; | |
252 } | 259 } |
253 } else if (target is LibrarySpecificUnit) { | 260 } else if (target is LibrarySpecificUnit) { |
254 if (result == CREATED_RESOLVED_UNIT1 || | 261 if (result == CREATED_RESOLVED_UNIT1 || |
255 result == CREATED_RESOLVED_UNIT2 || | 262 result == CREATED_RESOLVED_UNIT2 || |
256 result == CREATED_RESOLVED_UNIT3 || | 263 result == CREATED_RESOLVED_UNIT3 || |
257 result == CREATED_RESOLVED_UNIT4 || | 264 result == CREATED_RESOLVED_UNIT4 || |
258 result == CREATED_RESOLVED_UNIT5 || | 265 result == CREATED_RESOLVED_UNIT5 || |
259 result == CREATED_RESOLVED_UNIT6 || | 266 result == CREATED_RESOLVED_UNIT6 || |
260 result == CREATED_RESOLVED_UNIT7 || | 267 result == CREATED_RESOLVED_UNIT7 || |
261 result == CREATED_RESOLVED_UNIT8 || | 268 result == CREATED_RESOLVED_UNIT8 || |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 */ | 497 */ |
491 @deprecated | 498 @deprecated |
492 class _InSummaryFallbackSource extends FileBasedSource | 499 class _InSummaryFallbackSource extends FileBasedSource |
493 implements InSummarySource { | 500 implements InSummarySource { |
494 @override | 501 @override |
495 final String summaryPath; | 502 final String summaryPath; |
496 | 503 |
497 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) | 504 _InSummaryFallbackSource(JavaFile file, Uri uri, this.summaryPath) |
498 : super(file, uri); | 505 : super(file, uri); |
499 } | 506 } |
OLD | NEW |