void (@NotNull SdkType extension) { Set<Sdk> toRemove = new HashSet<>(); for (Sdk sdk : mySdks) { SdkTypeId sdkType = sdk.getSdkType(); if (sdkType == extension) { if (sdk instanceof ProjectJdkImpl) { Element additionalDataElement = saveSdkAdditionalData(sdk); ((ProjectJdkImpl)sdk).changeType(UnknownSdkType.getInstance(sdkType.getName()), additionalDataElement); } else { //sdk was dynamically added by a plugin so we can only remove it toRemove.add(sdk); } } } for (Sdk sdk : toRemove) { removeJdk(sdk); } }