Skip to content

Commit d9ca97a

Browse files
author
Anna Gringauze
authored
Split SDK configuration validation into components (#1589)
1 parent e7c3435 commit d9ca97a

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 13.1.1-dev
22
- Add column information to breakpoints to allow precise breakpoint placement.
3+
- Split SDK validation methods to allow validation of separate components.
34

45
## 13.1.0
56
- Update _fe_analyzer_shared to version ^38.0.0.

dwds/lib/src/utilities/sdk_configuration.dart

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ class SdkConfiguration {
7070
fileSystem ??= const LocalFileSystem();
7171

7272
validateSdkDir(fileSystem: fileSystem);
73+
validateSummaries(fileSystem: fileSystem);
74+
validateLibrariesSpec(fileSystem: fileSystem);
75+
validateCompilerWorker(fileSystem: fileSystem);
76+
}
77+
78+
/// Throws [InvalidSdkConfigurationException] if SDK root does not
79+
/// exist on the disk.
80+
void validateSdkDir({FileSystem fileSystem}) {
81+
fileSystem ??= const LocalFileSystem();
82+
if (sdkDirectory == null ||
83+
!fileSystem.directory(sdkDirectory).existsSync()) {
84+
throw InvalidSdkConfigurationException(
85+
'Sdk directory $sdkDirectory does not exist');
86+
}
87+
}
88+
89+
void validateSummaries({FileSystem fileSystem}) {
90+
fileSystem ??= const LocalFileSystem();
7391

7492
if (unsoundSdkSummaryPath == null ||
7593
!fileSystem.file(unsoundSdkSummaryPath).existsSync()) {
@@ -82,29 +100,26 @@ class SdkConfiguration {
82100
throw InvalidSdkConfigurationException(
83101
'Sdk summary $soundSdkSummaryPath does not exist');
84102
}
103+
}
104+
105+
void validateLibrariesSpec({FileSystem fileSystem}) {
106+
fileSystem ??= const LocalFileSystem();
85107

86108
if (librariesPath == null || !fileSystem.file(librariesPath).existsSync()) {
87109
throw InvalidSdkConfigurationException(
88110
'Libraries spec $librariesPath does not exist');
89111
}
112+
}
113+
114+
void validateCompilerWorker({FileSystem fileSystem}) {
115+
fileSystem ??= const LocalFileSystem();
90116

91117
if (compilerWorkerPath == null ||
92118
!fileSystem.file(compilerWorkerPath).existsSync()) {
93119
throw InvalidSdkConfigurationException(
94120
'Compiler worker $compilerWorkerPath does not exist');
95121
}
96122
}
97-
98-
/// Throws [InvalidSdkConfigurationException] if SDK root does not
99-
/// exist on the disk.
100-
void validateSdkDir({FileSystem fileSystem}) {
101-
fileSystem ??= const LocalFileSystem();
102-
if (sdkDirectory == null ||
103-
!fileSystem.directory(sdkDirectory).existsSync()) {
104-
throw InvalidSdkConfigurationException(
105-
'Sdk directory $sdkDirectory does not exist');
106-
}
107-
}
108123
}
109124

110125
/// Implementation for the default SDK configuration layout.

0 commit comments

Comments
 (0)