Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify the analyzer of deleted files #3584

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.4.1-wip

- Fix an issue where deleted files were not removed from the analysis engine,
and were still accessible via the analyzer apis.

## 2.4.0

- Deprecate the unnamed `AnalyzerResolvers` constructor, an replace it with the
Expand Down
1 change: 1 addition & 0 deletions build_resolvers/lib/src/build_asset_uri_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class BuildAssetUriResolver extends UriResolver {
_cachedAssetDigests.remove(id);
if (resourceProvider.getFile(path).exists) {
resourceProvider.deleteFile(path);
_needsChangeFile.add(path);
}
return _AssetState(path, const {});
}
Expand Down
2 changes: 1 addition & 1 deletion build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_resolvers
version: 2.4.0
version: 2.4.1-wip
description: Resolve Dart code in a Builder
repository: https://github.com/dart-lang/build/tree/master/build_resolvers

Expand Down
46 changes: 46 additions & 0 deletions build_resolvers/test/resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,52 @@ void main() {
}, resolvers: resolvers);
});

test('handles removing deleted parts', () async {
var resolvers = AnalyzerResolvers();
await resolveSources({
'a|web/main.dart': '''
part 'main.g.dart';

class A implements B {}
''',
'a|web/main.g.dart': '''
part of 'main.dart';
class B {}
''',
}, (resolver) async {
var lib = await resolver.libraryFor(entryPoint);
var clazz = lib.getClass('A');
expect(clazz, isNotNull);
expect(clazz!.interfaces, hasLength(1));
expect(clazz.interfaces.first.getDisplayString(withNullability: false),
'B');
}, resolvers: resolvers);

// `resolveSources` actually completes prior to the build step being
// done, which causes this `reset` call to fail. After a few microtasks
// it succeeds though.
var tries = 0;
while (tries++ < 5) {
await Future.value(null);
try {
resolvers.reset();
} catch (_) {}
}

await resolveSources({
'a|web/main.dart': '''
part 'main.g.dart';

class A implements B {}
''',
}, (resolver) async {
var lib = await resolver.libraryFor(entryPoint);
var clazz = lib.getClass('A');
expect(clazz, isNotNull);
expect(clazz!.interfaces, isEmpty);
}, resolvers: resolvers);
});

test('should list all libraries', () {
return resolveSources({
'a|web/main.dart': '''
Expand Down
Loading