mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-182633 External system: do not propose to restore removed modules created for the project preview
This commit is contained in:
+28
@@ -76,6 +76,8 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
private final AtomicReference<ExternalProjectsViewState> myExternalProjectsViewState = new AtomicReference<>(
|
||||
new ExternalProjectsViewState()
|
||||
);
|
||||
private final AtomicReference<Map<String/* external project config path */, SyncType>> myProjectSyncType =
|
||||
new AtomicReference<>(ContainerUtilRt.<String, SyncType>newHashMap());
|
||||
|
||||
@NotNull private final ProjectSystemId myExternalSystemId;
|
||||
@NotNull private final Project myProject;
|
||||
@@ -129,6 +131,15 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator<Map.Entry<String, SyncType>> it = myProjectSyncType.get().entrySet().iterator(); it.hasNext(); ) {
|
||||
Map.Entry<String, SyncType> entry = it.next();
|
||||
if (linkedProjectPathsToForget.contains(entry.getKey())
|
||||
|| linkedProjectPathsToForget.contains(ExternalSystemApiUtil.getRootProjectPath(entry.getKey(), myExternalSystemId, myProject)))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Long> modificationStamps = myExternalConfigModificationStamps.get();
|
||||
for (String path : linkedProjectPathsToForget) {
|
||||
modificationStamps.remove(path);
|
||||
@@ -200,6 +211,16 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
myExternalProjectsViewState.set(externalProjectsViewState);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, SyncType> getProjectSyncType() {
|
||||
return myProjectSyncType.get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public void setProjectSyncType(@NotNull Map<String, SyncType> projectSyncType) {
|
||||
// Required for IJ serialization.
|
||||
myProjectSyncType.set(projectSyncType);
|
||||
}
|
||||
public void fillState(@NotNull State state) {
|
||||
if (PRESERVE_EXPAND_STATE) {
|
||||
state.tasksExpandState = myExpandStates.get();
|
||||
@@ -213,6 +234,7 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
state.modificationStamps = myExternalConfigModificationStamps.get();
|
||||
state.projectBuildClasspath = myProjectBuildClasspath.get();
|
||||
state.externalProjectsViewState = myExternalProjectsViewState.get();
|
||||
state.projectSyncType = myProjectSyncType.get();
|
||||
}
|
||||
|
||||
public void loadState(@NotNull State state) {
|
||||
@@ -221,6 +243,7 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
setIfNotNull(myAvailableTasks, state.availableTasks);
|
||||
setIfNotNull(myExternalConfigModificationStamps, state.modificationStamps);
|
||||
setIfNotNull(myProjectBuildClasspath, state.projectBuildClasspath);
|
||||
setIfNotNull(myProjectSyncType, state.projectSyncType);
|
||||
myExternalProjectsViewState.set(state.externalProjectsViewState);
|
||||
if (state.recentTasks != null) {
|
||||
List<ExternalTaskExecutionInfo> recentTasks = myRecentTasks.get();
|
||||
@@ -281,5 +304,10 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
= ContainerUtilRt.newHashMap();
|
||||
public Map<String/* linked project path */, ExternalProjectBuildClasspathPojo> projectBuildClasspath = ContainerUtilRt.newHashMap();
|
||||
public ExternalProjectsViewState externalProjectsViewState;
|
||||
public Map<String/* linked project path */, SyncType> projectSyncType = ContainerUtilRt.newHashMap();
|
||||
}
|
||||
|
||||
public enum SyncType {
|
||||
PREVIEW, IMPORT, RE_IMPORT
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -31,6 +31,8 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.project.*;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModelsProvider;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings.SyncType;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.module.*;
|
||||
@@ -248,10 +250,12 @@ public abstract class AbstractModuleDataService<E extends ModuleData> extends Ab
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractExternalSystemLocalSettings localSettings = ExternalSystemApiUtil.getLocalSettings(project, projectData.getOwner());
|
||||
SyncType syncType = localSettings.getProjectSyncType().get(projectData.getLinkedExternalProjectPath());
|
||||
for (Module module : modules) {
|
||||
if (module.isDisposed()) continue;
|
||||
String path = module.getModuleFilePath();
|
||||
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
if (!ApplicationManager.getApplication().isHeadlessEnvironment() && syncType == SyncType.RE_IMPORT) {
|
||||
try {
|
||||
// we need to save module configuration before dispose, to get the up-to-date content of the unlinked module iml
|
||||
ServiceKt.getStateStore(module).save(new ArrayList<>());
|
||||
|
||||
+9
@@ -72,6 +72,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.ContentRootDat
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
|
||||
import com.intellij.openapi.externalSystem.task.TaskCallback;
|
||||
@@ -115,6 +116,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings.SyncType.*;
|
||||
import static com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.doWriteAction;
|
||||
import static com.intellij.util.containers.ContainerUtil.*;
|
||||
|
||||
@@ -390,6 +392,13 @@ public class ExternalSystemUtil {
|
||||
else {
|
||||
projectName = projectFile.getName();
|
||||
}
|
||||
|
||||
AbstractExternalSystemLocalSettings localSettings = ExternalSystemApiUtil.getLocalSettings(project, externalSystemId);
|
||||
AbstractExternalSystemLocalSettings.SyncType syncType =
|
||||
isPreviewMode ? PREVIEW :
|
||||
localSettings.getProjectSyncType().get(externalProjectPath) == PREVIEW ? IMPORT : RE_IMPORT;
|
||||
localSettings.getProjectSyncType().put(externalProjectPath, syncType);
|
||||
|
||||
final ExternalSystemResolveProjectTask myTask =
|
||||
new ExternalSystemResolveProjectTask(externalSystemId, project, externalProjectPath, vmOptions, arguments, isPreviewMode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user