Skip to content

Commit 168b720

Browse files
keertipcommit-bot@chromium.org
authored andcommitted
Fix finding third party analysis options.
Change-Id: If6792018fa9a4a64316be034dfa4b6e14c2e03d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166124 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent 7190940 commit 168b720

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,17 @@ class FileResolver {
462462
}) {
463463
YamlMap optionMap;
464464

465-
var optionsFile = performance.run('findOptionsFile', (_) {
466-
var folder = resourceProvider.getFile(path).parent;
467-
return _findOptionsFile(folder);
468-
});
465+
var separator = resourceProvider.pathContext.separator;
466+
var isThirdParty =
467+
path.contains('${separator}third_party${separator}dart$separator');
468+
469+
File optionsFile;
470+
if (!isThirdParty) {
471+
optionsFile = performance.run('findOptionsFile', (_) {
472+
var folder = resourceProvider.getFile(path).parent;
473+
return _findOptionsFile(folder);
474+
});
475+
}
469476

470477
if (optionsFile != null) {
471478
performance.run('getOptionsFromFile', (_) {
@@ -479,9 +486,7 @@ class FileResolver {
479486
} else {
480487
var source = performance.run('defaultOptions', (_) {
481488
if (workspace is WorkspaceWithDefaultAnalysisOptions) {
482-
var separator = resourceProvider.pathContext.separator;
483-
if (path
484-
.contains('${separator}third_party${separator}dart$separator')) {
489+
if (isThirdParty) {
485490
return sourceFactory.forUri(
486491
WorkspaceWithDefaultAnalysisOptions.thirdPartyUri,
487492
);

pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ analyzer:
312312
implicit-casts: false
313313
''');
314314

315+
newFile('/workspace/thid_party/dart/aaa/analysis_options.yaml',
316+
content: r'''
317+
analyzer:
318+
strong-mode:
319+
implicit-casts: true
320+
''');
321+
315322
var aPath = convertPath('/workspace/third_party/dart/aaa/lib/a.dart');
316323
await assertErrorsInFile(aPath, r'''
317324
num a = 0;

0 commit comments

Comments
 (0)