Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
| 10 import 'package:analyzer/src/dart/analysis/driver.dart'; | 10 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * The set of files were reported as changed through [changeFile] and not | 56 * The set of files were reported as changed through [changeFile] and not |
| 57 * checked for actual changes yet. | 57 * checked for actual changes yet. |
| 58 */ | 58 */ |
| 59 final _changedFiles = new LinkedHashSet<String>(); | 59 final _changedFiles = new LinkedHashSet<String>(); |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * The set of files that are currently scheduled for analysis. | 62 * The set of files that are currently scheduled for analysis. |
| 63 */ | 63 */ |
| 64 final _pendingFiles = new LinkedHashSet<String>(); | 64 var _pendingFiles = new LinkedHashSet<String>(); |
| 65 | 65 |
| 66 FileTracker( | 66 FileTracker( |
| 67 this.logger, | 67 this.logger, |
| 68 ByteStore byteStore, | 68 ByteStore byteStore, |
| 69 FileContentOverlay contentOverlay, | 69 FileContentOverlay contentOverlay, |
| 70 ResourceProvider resourceProvider, | 70 ResourceProvider resourceProvider, |
| 71 SourceFactory sourceFactory, | 71 SourceFactory sourceFactory, |
| 72 AnalysisOptions analysisOptions, | 72 AnalysisOptions analysisOptions, |
| 73 Uint32List salt, | 73 Uint32List salt, |
| 74 this._changeHook) | 74 this._changeHook) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 List<FileState> files = fsState.getFilesForPath(path); | 165 List<FileState> files = fsState.getFilesForPath(path); |
| 166 for (FileState file in files) { | 166 for (FileState file in files) { |
| 167 bool apiChanged = file.refresh(); | 167 bool apiChanged = file.refresh(); |
| 168 if (apiChanged) { | 168 if (apiChanged) { |
| 169 anyApiChanged = true; | 169 anyApiChanged = true; |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 if (anyApiChanged) { | 172 if (anyApiChanged) { |
| 173 logger.writeln('API signatures mismatch found for $path'); | 173 logger.writeln('API signatures mismatch found for $path'); |
| 174 // TODO(scheglov) schedule analysis of only affected files | 174 // TODO(scheglov) schedule analysis of only affected files |
| 175 _pendingFiles.addAll(addedFiles); | 175 var pendingFiles = new LinkedHashSet<String>(); |
| 176 | |
| 177 // Add the changed file. | |
| 178 if (addedFiles.contains(path)) { | |
| 179 pendingFiles.add(path); | |
| 180 } | |
| 181 | |
| 182 // Add files that directly import the changed file. | |
| 183 for (String addedPath in addedFiles) { | |
| 184 FileState addedFile = fsState.getFileForPath(addedPath); | |
| 185 for (FileState changedFile in files) { | |
| 186 if (addedFile.importedFiles.contains(changedFile)) { | |
| 187 pendingFiles.add(addedPath); | |
| 188 } | |
| 189 } | |
| 190 } | |
| 191 | |
| 192 // Add files with errors or warnings that might be fixed. | |
| 193 for (String addedPath in addedFiles) { | |
| 194 FileState addedFile = fsState.getFileForPath(addedPath); | |
| 195 if (addedFile.hasErrorOrWarning) { | |
| 196 pendingFiles.add(addedPath); | |
| 197 } | |
| 198 } | |
| 199 | |
| 200 // Add all previous pending files. | |
| 201 pendingFiles.addAll(_pendingFiles); | |
|
Brian Wilkerson
2017/04/10 18:17:38
Are we sure we want to add previous pending files
scheglov
2017/04/10 18:51:58
Well, we would need a way to distinguish which fil
| |
| 202 | |
| 203 // Add all the rest. | |
| 204 pendingFiles.addAll(addedFiles); | |
| 205 | |
| 206 // Replace pending files. | |
| 207 _pendingFiles = pendingFiles; | |
| 176 } | 208 } |
| 177 return files[0]; | 209 return files[0]; |
| 178 }); | 210 }); |
| 179 } | 211 } |
| 180 | 212 |
| 181 /** | 213 /** |
| 182 * If at least one file is in the "changed files" set, determines the impact | 214 * If at least one file is in the "changed files" set, determines the impact |
| 183 * of the change, updates the set of pending files, and returns `true`. | 215 * of the change, updates the set of pending files, and returns `true`. |
| 184 * | 216 * |
| 185 * If no files are in the "changed files" set, returns `false`. | 217 * If no files are in the "changed files" set, returns `false`. |
| 186 */ | 218 */ |
| 187 bool verifyChangedFilesIfNeeded() { | 219 bool verifyChangedFilesIfNeeded() { |
| 188 // Verify all changed files one at a time. | 220 // Verify all changed files one at a time. |
| 189 if (_changedFiles.isNotEmpty) { | 221 if (_changedFiles.isNotEmpty) { |
| 190 String path = _changedFiles.first; | 222 String path = _changedFiles.first; |
| 191 _changedFiles.remove(path); | 223 _changedFiles.remove(path); |
| 192 // If the file has not been accessed yet, we either will eventually read | 224 // If the file has not been accessed yet, we either will eventually read |
| 193 // it later while analyzing one of the added files, or don't need it. | 225 // it later while analyzing one of the added files, or don't need it. |
| 194 if (fsState.knownFilePaths.contains(path)) { | 226 if (fsState.knownFilePaths.contains(path)) { |
| 195 verifyApiSignature(path); | 227 verifyApiSignature(path); |
| 196 } | 228 } |
| 197 return true; | 229 return true; |
| 198 } | 230 } |
| 199 return false; | 231 return false; |
| 200 } | 232 } |
| 201 } | 233 } |
| OLD | NEW |