From 460f235f44c30e108f85cc31d98cea8a4621c5b5 Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Tue, 19 Apr 2022 10:08:05 -0700 Subject: [PATCH] Split SDK configuration validation into components --- dwds/CHANGELOG.md | 1 + dwds/lib/src/utilities/sdk_configuration.dart | 37 +++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 66c6bfff4..f7dbb4db0 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,5 +1,6 @@ ## 13.1.1-dev - Add column information to breakpoints to allow precise breakpoint placement. +- Split SDK validation methods to allow validation of separate components. ## 13.1.0 - Update _fe_analyzer_shared to version ^38.0.0. diff --git a/dwds/lib/src/utilities/sdk_configuration.dart b/dwds/lib/src/utilities/sdk_configuration.dart index bcb8a16d4..114e18f66 100644 --- a/dwds/lib/src/utilities/sdk_configuration.dart +++ b/dwds/lib/src/utilities/sdk_configuration.dart @@ -70,6 +70,24 @@ class SdkConfiguration { fileSystem ??= const LocalFileSystem(); validateSdkDir(fileSystem: fileSystem); + validateSummaries(fileSystem: fileSystem); + validateLibrariesSpec(fileSystem: fileSystem); + validateCompilerWorker(fileSystem: fileSystem); + } + + /// Throws [InvalidSdkConfigurationException] if SDK root does not + /// exist on the disk. + void validateSdkDir({FileSystem fileSystem}) { + fileSystem ??= const LocalFileSystem(); + if (sdkDirectory == null || + !fileSystem.directory(sdkDirectory).existsSync()) { + throw InvalidSdkConfigurationException( + 'Sdk directory $sdkDirectory does not exist'); + } + } + + void validateSummaries({FileSystem fileSystem}) { + fileSystem ??= const LocalFileSystem(); if (unsoundSdkSummaryPath == null || !fileSystem.file(unsoundSdkSummaryPath).existsSync()) { @@ -82,11 +100,19 @@ class SdkConfiguration { throw InvalidSdkConfigurationException( 'Sdk summary $soundSdkSummaryPath does not exist'); } + } + + void validateLibrariesSpec({FileSystem fileSystem}) { + fileSystem ??= const LocalFileSystem(); if (librariesPath == null || !fileSystem.file(librariesPath).existsSync()) { throw InvalidSdkConfigurationException( 'Libraries spec $librariesPath does not exist'); } + } + + void validateCompilerWorker({FileSystem fileSystem}) { + fileSystem ??= const LocalFileSystem(); if (compilerWorkerPath == null || !fileSystem.file(compilerWorkerPath).existsSync()) { @@ -94,17 +120,6 @@ class SdkConfiguration { 'Compiler worker $compilerWorkerPath does not exist'); } } - - /// Throws [InvalidSdkConfigurationException] if SDK root does not - /// exist on the disk. - void validateSdkDir({FileSystem fileSystem}) { - fileSystem ??= const LocalFileSystem(); - if (sdkDirectory == null || - !fileSystem.directory(sdkDirectory).existsSync()) { - throw InvalidSdkConfigurationException( - 'Sdk directory $sdkDirectory does not exist'); - } - } } /// Implementation for the default SDK configuration layout.