Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e7281c5

Browse files
author
Dart CI
committed
Version 2.18.0-178.0.dev
Merge commit '5263e15e99d967bd9cec5f8b05fac95224bd768e' into 'dev'
2 parents 51f104e + 5263e15 commit e7281c5

21 files changed

+535
-129
lines changed

pkg/analysis_server/tool/lsp_spec/codegen_dart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ List<N> _getSortedUnique<N extends LspEntity>(List<N> items) {
151151
final nameTypeKey = '${item.name}|${item.runtimeType}';
152152
if (uniqueByName.containsKey(nameTypeKey)) {
153153
// At the time of writing, there were two duplicated types:
154-
// - TextDocumentSyncKind (same defintion in both places)
154+
// - TextDocumentSyncKind (same definition in both places)
155155
// - TextDocumentSyncOptions (first definition is just a subset)
156156
// If this list grows, consider handling this better - or try to have the
157-
// spec updated to be unambigious.
157+
// spec updated to be unambiguous.
158158
print('WARN: More than one definition for $nameTypeKey.');
159159
}
160160

pkg/analyzer/lib/src/dart/micro/library_graph.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ class FileSystemState {
467467

468468
var unusedPaths = _pathToFile.keys.toSet();
469469
unusedPaths.removeAll(allReferenced);
470-
testView.removedPaths = unusedPaths;
471470

472471
var removedFiles = <FileState>[];
473472
for (var path in unusedPaths) {
@@ -512,7 +511,6 @@ class FileSystemState {
512511

513512
class FileSystemStateTestView {
514513
final List<String> partsDiscoveredLibraries = [];
515-
Set<String> removedPaths = {};
516514
}
517515

518516
class FileSystemStateTimer {

pkg/analyzer/lib/src/dart/micro/resolve_file.dart

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class FileResolver {
116116
LibraryContext? libraryContext;
117117

118118
/// List of keys for cache elements that are invalidated. Track elements that
119-
/// are invalidated during [changeFile]. Used in [releaseAndClearRemovedIds]
119+
/// are invalidated during [changeFiles]. Used in [releaseAndClearRemovedIds]
120120
/// to release the cache items and is then cleared.
121121
final Set<String> removedCacheKeys = {};
122122

123-
/// The cache of file results, cleared on [changeFile].
123+
/// The cache of file results, cleared on [changeFiles].
124124
///
125125
/// It is used to allow assists and fixes without resolving the same file
126126
/// multiple times, as we compute more than one assist, or fixes when there
@@ -158,29 +158,43 @@ class FileResolver {
158158
/// Update the resolver to reflect the fact that the file with the given
159159
/// [path] was changed. We need to make sure that when this file, of any file
160160
/// that directly or indirectly referenced it, is resolved, we used the new
161-
/// state of the file. Updates [removedCacheIds] with the ids of the invalidated
161+
/// state of the file. Updates [removedCacheKeys] with the ids of the invalidated
162162
/// items, used in [releaseAndClearRemovedIds] to release the cache items.
163+
/// TODO(scheglov) Remove [releaseKeys] when removing [changeFile].
164+
@Deprecated('Use changeFiles() instead')
163165
void changeFile(String path) {
166+
changeFiles([path], releaseKeys: false);
167+
}
168+
169+
/// Update the resolver to reflect the fact that the files with the given
170+
/// [paths] were changed. For each specified file we need to make sure that
171+
/// when the file, of any file that directly or indirectly referenced it,
172+
/// is resolved, we use the new state of the file.
173+
void changeFiles(List<String> paths, {bool releaseKeys = true}) {
164174
if (fsState == null) {
165175
return;
166176
}
167177

168178
// Forget all results, anything is potentially affected.
169179
cachedResults.clear();
170180

171-
// Remove this file and all files that transitively depend on it.
172-
var removedFiles = <FileState>[];
173-
fsState!.changeFile(path, removedFiles);
181+
// Remove the specified files and files that transitively depend on it.
182+
final removedFiles = <FileState>[];
183+
for (final path in paths) {
184+
fsState!.changeFile(path, removedFiles);
185+
}
174186

175187
// Schedule disposing references to cached unlinked data.
176-
for (var removedFile in removedFiles) {
188+
for (final removedFile in removedFiles) {
177189
removedCacheKeys.add(removedFile.unlinkedKey);
178190
}
179191

180192
// Remove libraries represented by removed files.
181193
// If we need these libraries later, we will relink and reattach them.
182-
if (libraryContext != null) {
183-
libraryContext!.remove(removedFiles, removedCacheKeys);
194+
libraryContext?.remove(removedFiles, removedCacheKeys);
195+
196+
if (releaseKeys) {
197+
releaseAndClearRemovedIds();
184198
}
185199
}
186200

@@ -445,12 +459,14 @@ class FileResolver {
445459
/// Remove cached [FileState]'s that were not used in the current analysis
446460
/// session. The list of files analyzed is used to compute the set of unused
447461
/// [FileState]'s. Adds the cache id's for the removed [FileState]'s to
448-
/// [removedCacheIds].
462+
/// [removedCacheKeys].
449463
void removeFilesNotNecessaryForAnalysisOf(List<String> files) {
450464
var removedFiles = fsState!.removeUnusedFiles(files);
451465
for (var removedFile in removedFiles) {
452466
removedCacheKeys.add(removedFile.unlinkedKey);
453467
}
468+
libraryContext?.remove(removedFiles, removedCacheKeys);
469+
releaseAndClearRemovedIds();
454470
}
455471

456472
/// The [completionLine] and [completionColumn] are zero based.

0 commit comments

Comments
 (0)