Skip to content

Commit 541ffb9

Browse files
authored
Merge pull request #922 from bohdan-harniuk/920-add-new-magento-version-support
920: Added new Magento version support (2.4.4-beta4) for the UCT feature
2 parents 0bc74a8 + 7e80a16 commit 541ffb9

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed
72.6 KB
Binary file not shown.
Binary file not shown.
739 KB
Binary file not shown.

src/com/magento/idea/magento2uct/packages/SupportedVersion.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public enum SupportedVersion {
3838
V2422("2.4.2-p2"),
3939
V243("2.4.3"),
4040
V2431("2.4.3-p1"),
41-
V2441("2.4.4-beta1"),
42-
V2442("2.4.4-beta2");
41+
V2444("2.4.4-beta4");
4342

4443
private final String version;
4544

src/com/magento/idea/magento2uct/versioning/VersionStateManager.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public final class VersionStateManager {
2424
private final ExistenceStateIndex existenceStateIndex;
2525
private final ApiCoverageStateIndex apiCoverageStateIndex;
2626
private final Boolean isSetIgnoreFlag;
27-
private final SupportedVersion currentVersion;
28-
private final SupportedVersion targetVersion;
27+
private SupportedVersion currentVersion;
28+
private SupportedVersion targetVersion;
2929
private final List<SupportedVersion> versionsToLoad;
3030

3131
/**
@@ -48,6 +48,7 @@ public static synchronized VersionStateManager getInstance(
4848
)) {
4949
instance = new VersionStateManager(project);
5050
}
51+
5152
return instance;
5253
}
5354

@@ -115,6 +116,8 @@ private VersionStateManager(final @NotNull Project project) {
115116
currentVersion = settingsService.getCurrentVersionOrDefault();
116117
targetVersion = settingsService.getTargetVersion();
117118
versionsToLoad = new LinkedList<>();
119+
// Correct settings if stored data isn't valid for current supported versions state.
120+
correctSettings(project);
118121

119122
deprecationStateIndex = new DeprecationStateIndex();
120123
compute(deprecationStateIndex);
@@ -126,6 +129,35 @@ private VersionStateManager(final @NotNull Project project) {
126129
compute(apiCoverageStateIndex);
127130
}
128131

132+
/**
133+
* Correct settings if corrupted.
134+
*
135+
* @param project Project
136+
*/
137+
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
138+
private synchronized void correctSettings(final @NotNull Project project) {
139+
final UctSettingsService settingsService = UctSettingsService.getInstance(project);
140+
final List<String> allVersions = SupportedVersion.getSupportedVersions();
141+
142+
if (currentVersion == null
143+
|| SupportedVersion.getVersion(currentVersion.getVersion()) == null) {
144+
final SupportedVersion correctCurrentVersion = SupportedVersion.getVersion(
145+
allVersions.get(0)
146+
);
147+
settingsService.setCurrentVersion(correctCurrentVersion);
148+
currentVersion = correctCurrentVersion;
149+
}
150+
151+
if (targetVersion == null
152+
|| SupportedVersion.getVersion(targetVersion.getVersion()) == null) {
153+
final SupportedVersion correctTargetVersion = SupportedVersion.getVersion(
154+
allVersions.get(allVersions.size() - 1)
155+
);
156+
settingsService.setTargetVersion(correctTargetVersion);
157+
targetVersion = correctTargetVersion;
158+
}
159+
}
160+
129161
/**
130162
* Check if current instance is valid for settings.
131163
*

0 commit comments

Comments
 (0)