Skip to content

Split SDK configuration validation into components #1589

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

Merged
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
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
37 changes: 26 additions & 11 deletions dwds/lib/src/utilities/sdk_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -82,29 +100,26 @@ 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()) {
throw InvalidSdkConfigurationException(
'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.
Expand Down