Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit ae79c8c

Browse files
authored
Change from subclassing PhysicalResourceProvider (#2341)
change from subclassing PhysicalResourceProvider
1 parent f9aee2c commit ae79c8c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

lib/src/test_utilities/test_resource_provider.dart

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import 'dart:io';
77
import 'package:analyzer/file_system/file_system.dart' as file_system;
88
import 'package:analyzer/file_system/memory_file_system.dart';
99
import 'package:analyzer/file_system/physical_file_system.dart';
10+
1011
// ignore: implementation_imports
1112
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
13+
import 'package:path/path.dart' as path;
1214

1315
import '../analyzer.dart';
1416

@@ -36,26 +38,42 @@ DartLinter buildDriver(LintRule rule, File file, {String analysisOptions}) {
3638

3739
/// A resource provider that accesses entities in a MemoryResourceProvider,
3840
/// falling back to the PhysicalResourceProvider when they don't exist.
39-
class TestResourceProvider extends PhysicalResourceProvider {
40-
MemoryResourceProvider memoryResourceProvider;
41+
class TestResourceProvider extends file_system.ResourceProvider {
42+
static final PhysicalResourceProvider physicalResourceProvider =
43+
PhysicalResourceProvider.INSTANCE;
44+
45+
final MemoryResourceProvider memoryResourceProvider;
4146

42-
TestResourceProvider(this.memoryResourceProvider) : super(null);
47+
TestResourceProvider(this.memoryResourceProvider);
4348

4449
@override
4550
file_system.File getFile(String path) {
4651
final file = memoryResourceProvider.getFile(path);
47-
return file.exists ? file : super.getFile(path);
52+
return file.exists ? file : physicalResourceProvider.getFile(path);
4853
}
4954

5055
@override
5156
file_system.Folder getFolder(String path) {
5257
final folder = memoryResourceProvider.getFolder(path);
53-
return folder.exists ? folder : super.getFolder(path);
58+
return folder.exists ? folder : physicalResourceProvider.getFolder(path);
5459
}
5560

5661
@override
5762
file_system.Resource getResource(String path) {
5863
final resource = memoryResourceProvider.getResource(path);
59-
return resource.exists ? resource : super.getResource(path);
64+
return resource.exists
65+
? resource
66+
: physicalResourceProvider.getResource(path);
6067
}
68+
69+
@override
70+
Future<List<int>> getModificationTimes(List<Source> sources) =>
71+
physicalResourceProvider.getModificationTimes(sources);
72+
73+
@override
74+
file_system.Folder getStateLocation(String pluginId) =>
75+
physicalResourceProvider.getStateLocation(pluginId);
76+
77+
@override
78+
path.Context get pathContext => physicalResourceProvider.pathContext;
6179
}

0 commit comments

Comments
 (0)