Skip to content
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
Binary file modified resources/uct/api/indexes.API_COVERAGE.idc
Binary file not shown.
Binary file not shown.
Binary file modified resources/uct/existence/indexes.EXISTENCE.idc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public enum SupportedVersion {
V2422("2.4.2-p2"),
V243("2.4.3"),
V2431("2.4.3-p1"),
V2441("2.4.4-beta1"),
V2442("2.4.4-beta2");
V2444("2.4.4-beta4");

private final String version;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public final class VersionStateManager {
private final ExistenceStateIndex existenceStateIndex;
private final ApiCoverageStateIndex apiCoverageStateIndex;
private final Boolean isSetIgnoreFlag;
private final SupportedVersion currentVersion;
private final SupportedVersion targetVersion;
private SupportedVersion currentVersion;
private SupportedVersion targetVersion;
private final List<SupportedVersion> versionsToLoad;

/**
Expand All @@ -48,6 +48,7 @@ public static synchronized VersionStateManager getInstance(
)) {
instance = new VersionStateManager(project);
}

return instance;
}

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

deprecationStateIndex = new DeprecationStateIndex();
compute(deprecationStateIndex);
Expand All @@ -126,6 +129,35 @@ private VersionStateManager(final @NotNull Project project) {
compute(apiCoverageStateIndex);
}

/**
* Correct settings if corrupted.
*
* @param project Project
*/
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
private synchronized void correctSettings(final @NotNull Project project) {
final UctSettingsService settingsService = UctSettingsService.getInstance(project);
final List<String> allVersions = SupportedVersion.getSupportedVersions();

if (currentVersion == null
|| SupportedVersion.getVersion(currentVersion.getVersion()) == null) {
final SupportedVersion correctCurrentVersion = SupportedVersion.getVersion(
allVersions.get(0)
);
settingsService.setCurrentVersion(correctCurrentVersion);
currentVersion = correctCurrentVersion;
}

if (targetVersion == null
|| SupportedVersion.getVersion(targetVersion.getVersion()) == null) {
final SupportedVersion correctTargetVersion = SupportedVersion.getVersion(
allVersions.get(allVersions.size() - 1)
);
settingsService.setTargetVersion(correctTargetVersion);
targetVersion = correctTargetVersion;
}
}

/**
* Check if current instance is valid for settings.
*
Expand Down