mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:21:54 +00:00
Change ResourceUriResolver to accept any file URI.
We don't really need to check that the corresponding resource is a file. Now it is a file, or a directory, the moment later it is not. We will try to read it, if we can - fine, if not - it does not exist. This makes my Flutter analysis benchmark about 3% faster. R=brianwilkerson@google.com Change-Id: I955be276c7a694a408c70f8f2d47dce75594ebc8 Reviewed-on: https://dart-review.googlesource.com/77243 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
6c577f0620
commit
25c659934a
|
@ -27,11 +27,8 @@ class ResourceUriResolver extends UriResolver {
|
|||
return null;
|
||||
}
|
||||
String path = fileUriToNormalizedPath(_provider.pathContext, uri);
|
||||
Resource resource = _provider.getResource(path);
|
||||
if (resource is File) {
|
||||
return resource.createSource(actualUri ?? uri);
|
||||
}
|
||||
return null;
|
||||
File file = _provider.getFile(path);
|
||||
return file.createSource(actualUri ?? uri);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -42,7 +42,9 @@ class ResourceUriResolverTest {
|
|||
void test_resolveAbsolute_folder() {
|
||||
var uri = provider.pathContext.toUri(provider.convertPath('/folder'));
|
||||
Source source = resolver.resolveAbsolute(uri);
|
||||
expect(source, isNull);
|
||||
expect(source, isNotNull);
|
||||
expect(source.exists(), isFalse);
|
||||
expect(source.fullName, provider.convertPath('/folder'));
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_notFile_dartUri() {
|
||||
|
|
|
@ -7417,9 +7417,9 @@ unit: b.dart
|
|||
var library = await checkLibrary('library my.lib; part "foo/";');
|
||||
checkElementText(library, r'''
|
||||
library my.lib;
|
||||
part '<unresolved>';
|
||||
part '';
|
||||
--------------------
|
||||
unit: null
|
||||
unit: foo
|
||||
|
||||
''');
|
||||
}
|
||||
|
|
|
@ -895,7 +895,7 @@ library lib;
|
|||
part '$invalidUri';
|
||||
'''
|
||||
});
|
||||
expect(libraryElement.parts, isEmpty);
|
||||
expect(libraryElement.parts, hasLength(1));
|
||||
}
|
||||
|
||||
test_perform_isLaunchable_inDefiningUnit() {
|
||||
|
|
Loading…
Reference in a new issue