mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
Revert "IDEA-351766 [ExternalSystem|Task|Execution] fix: removed the IDE project reference from the AbstractExternalSystemTask"
This reverts commit 977525c402b7e32d1cf4ac09051c12c01c8f74fd. In headless and synchronous mode, we have cases when the project sync is started during project initialization. The project isn't registered as opened in the ProjectManager service. GitOrigin-RevId: cbdb538bc702ec13e7171a8da181933ba2ad9ec3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4dd6d4ff65
commit
786dc6ef84
@@ -824,7 +824,6 @@ f:com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
|
||||
- findProject():com.intellij.openapi.project.Project
|
||||
- getId():J
|
||||
- getIdeProjectId():java.lang.String
|
||||
- getProject():com.intellij.openapi.project.Project
|
||||
- s:getProjectId(com.intellij.openapi.project.Project):java.lang.String
|
||||
- getProjectSystemId():com.intellij.openapi.externalSystem.model.ProjectSystemId
|
||||
- getType():com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.openapi.externalSystem.model.task;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.serviceContainer.AlreadyDisposedException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -73,14 +72,6 @@ public final class ExternalSystemTaskId implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @NotNull Project getProject() {
|
||||
Project project = findProject();
|
||||
if (project == null) {
|
||||
throw new AlreadyDisposedException(String.format("Project %s is closed", myProjectId));
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExternalSystemTaskType getType() {
|
||||
return myType;
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.serviceContainer.AlreadyDisposedException;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -35,6 +34,8 @@ public abstract class AbstractExternalSystemTask extends UserDataHolderBase impl
|
||||
new AtomicReference<>(ExternalSystemTaskState.NOT_STARTED);
|
||||
private final AtomicReference<Throwable> myError = new AtomicReference<>();
|
||||
|
||||
@NotNull private final transient Project myIdeProject;
|
||||
|
||||
@NotNull private final ExternalSystemTaskId myId;
|
||||
@NotNull private final ProjectSystemId myExternalSystemId;
|
||||
@NotNull private final String myExternalProjectPath;
|
||||
@@ -44,7 +45,8 @@ public abstract class AbstractExternalSystemTask extends UserDataHolderBase impl
|
||||
@NotNull Project project,
|
||||
@NotNull String externalProjectPath) {
|
||||
myExternalSystemId = id;
|
||||
myId = ExternalSystemTaskId.create(id, type, project);
|
||||
myIdeProject = project;
|
||||
myId = ExternalSystemTaskId.create(id, type, myIdeProject);
|
||||
myExternalProjectPath = externalProjectPath;
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ public abstract class AbstractExternalSystemTask extends UserDataHolderBase impl
|
||||
|
||||
@NotNull
|
||||
public Project getIdeProject() {
|
||||
return myId.getProject();
|
||||
return myIdeProject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -93,21 +95,17 @@ public abstract class AbstractExternalSystemTask extends UserDataHolderBase impl
|
||||
if (getState() != ExternalSystemTaskState.IN_PROGRESS) {
|
||||
return;
|
||||
}
|
||||
final ExternalSystemFacadeManager manager = ApplicationManager.getApplication().getService(ExternalSystemFacadeManager.class);
|
||||
try {
|
||||
final Project project = getIdeProject();
|
||||
final ExternalSystemFacadeManager manager = ApplicationManager.getApplication().getService(ExternalSystemFacadeManager.class);
|
||||
final RemoteExternalSystemFacade<?> facade = manager.getFacade(project, myExternalProjectPath, myExternalSystemId);
|
||||
final RemoteExternalSystemFacade<?> facade = manager.getFacade(myIdeProject, myExternalProjectPath, myExternalSystemId);
|
||||
setState(facade.isTaskInProgress(getId()) ? ExternalSystemTaskState.IN_PROGRESS : ExternalSystemTaskState.FAILED);
|
||||
}
|
||||
catch (AlreadyDisposedException e) {
|
||||
setState(ExternalSystemTaskState.FAILED);
|
||||
myError.set(e);
|
||||
LOG.debug(e);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
setState(ExternalSystemTaskState.FAILED);
|
||||
myError.set(e);
|
||||
LOG.warn(e);
|
||||
if (!myIdeProject.isDisposed()) {
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.backend.workspace.workspaceModel
|
||||
import com.intellij.platform.diagnostic.telemetry.helpers.use
|
||||
import com.intellij.platform.workspace.storage.MutableEntityStorage
|
||||
import com.intellij.serviceContainer.AlreadyDisposedException
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
@@ -78,6 +79,10 @@ object GradleSyncProjectConfigurator {
|
||||
|
||||
private suspend fun ExternalSystemTaskId.project(): Project {
|
||||
checkCanceled()
|
||||
return getProject()
|
||||
val project = findProject()
|
||||
if (project == null) {
|
||||
throw AlreadyDisposedException("Project $ideProjectId is closed")
|
||||
}
|
||||
return project
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user