mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[ExternalSystem|Sync] cleanup: remove ModifiableWorkspace's public usages
### Issues * IDEA-134885 Support substitution of library dependency with module dependency when the module is a part of another Maven or Gradle project GitOrigin-RevId: 9665bfdc9999d3c4691ae03ec799ed34b9082a61
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c65328ad52
commit
869a9954be
@@ -533,7 +533,6 @@ a:com.intellij.openapi.externalSystem.service.project.AbstractIdeModifiableModel
|
||||
- getModifiableModuleModel():com.intellij.openapi.module.ModifiableModuleModel
|
||||
- a:getModifiableProjectLibrariesModel():com.intellij.openapi.roots.libraries.LibraryTable$ModifiableModel
|
||||
- getModifiableRootModel(com.intellij.openapi.module.Module):com.intellij.openapi.roots.ModifiableRootModel
|
||||
- getModifiableWorkspace():com.intellij.openapi.externalSystem.service.project.ModifiableWorkspace
|
||||
- getModules():com.intellij.openapi.module.Module[]
|
||||
- getOrderEntries(com.intellij.openapi.module.Module):com.intellij.openapi.roots.OrderEntry[]
|
||||
- getProductionModuleName(com.intellij.openapi.module.Module):java.lang.String
|
||||
|
||||
@@ -217,8 +217,11 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
|
||||
return myModifiableLibraryModels.computeIfAbsent(library, k -> doGetModifiableLibraryModel(library));
|
||||
}
|
||||
|
||||
public @Nullable ModifiableWorkspace getModifiableWorkspace() {
|
||||
if (myModifiableWorkspace == null && ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) {
|
||||
private @Nullable ModifiableWorkspace getModifiableWorkspace() {
|
||||
if (!ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if (myModifiableWorkspace == null) {
|
||||
myModifiableWorkspace = doGetModifiableWorkspace();
|
||||
}
|
||||
return myModifiableWorkspace;
|
||||
@@ -314,28 +317,25 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
|
||||
|
||||
@Override
|
||||
public ModuleOrderEntry trySubstitute(Module ownerModule, LibraryOrderEntry libraryOrderEntry, ProjectCoordinate publicationId) {
|
||||
String workspaceModuleCandidate = findModuleByPublication(publicationId);
|
||||
ModifiableWorkspace workspace = getModifiableWorkspace();
|
||||
String workspaceModuleCandidate = workspace == null ? null : workspace.findModule(publicationId);
|
||||
Module workspaceModule = workspaceModuleCandidate == null ? null : findIdeModule(workspaceModuleCandidate);
|
||||
if (workspaceModule == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
ModifiableRootModel modifiableRootModel = getModifiableRootModel(ownerModule);
|
||||
ModuleOrderEntry moduleOrderEntry = modifiableRootModel.findModuleOrderEntry(workspaceModule);
|
||||
if (moduleOrderEntry == null) // if that module exists already (after re-import)
|
||||
moduleOrderEntry = modifiableRootModel.addModuleOrderEntry(workspaceModule);
|
||||
moduleOrderEntry.setScope(libraryOrderEntry.getScope());
|
||||
moduleOrderEntry.setExported(libraryOrderEntry.isExported());
|
||||
ModifiableWorkspace workspace = getModifiableWorkspace();
|
||||
|
||||
assert workspace != null;
|
||||
workspace.addSubstitution(ownerModule.getName(),
|
||||
workspaceModule.getName(),
|
||||
libraryOrderEntry.getLibraryName(),
|
||||
libraryOrderEntry.getScope());
|
||||
modifiableRootModel.removeOrderEntry(libraryOrderEntry);
|
||||
return moduleOrderEntry;
|
||||
ModifiableRootModel modifiableRootModel = getModifiableRootModel(ownerModule);
|
||||
ModuleOrderEntry moduleOrderEntry = modifiableRootModel.findModuleOrderEntry(workspaceModule);
|
||||
if (moduleOrderEntry == null) { // if that module exists already (after re-import)
|
||||
moduleOrderEntry = modifiableRootModel.addModuleOrderEntry(workspaceModule);
|
||||
}
|
||||
moduleOrderEntry.setScope(libraryOrderEntry.getScope());
|
||||
moduleOrderEntry.setExported(libraryOrderEntry.isExported());
|
||||
workspace.addSubstitution(ownerModule.getName(),
|
||||
workspaceModule.getName(),
|
||||
libraryOrderEntry.getLibraryName(),
|
||||
libraryOrderEntry.getScope());
|
||||
modifiableRootModel.removeOrderEntry(libraryOrderEntry);
|
||||
return moduleOrderEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,7 +382,7 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
|
||||
|
||||
Map<String, String> toSubstitute = new HashMap<>();
|
||||
ProjectDataManager projectDataManager = ProjectDataManager.getInstance();
|
||||
for (ExternalSystemManager<?, ?, ?, ?, ?> manager: ExternalSystemManager.EP_NAME.getIterable()) {
|
||||
ExternalSystemManager.EP_NAME.forEachExtensionSafe(manager -> {
|
||||
Collection<ExternalProjectInfo> projectsData = projectDataManager.getExternalProjectsData(myProject, manager.getSystemId());
|
||||
for (ExternalProjectInfo projectInfo: projectsData) {
|
||||
if (projectInfo.getExternalProjectStructure() == null) {
|
||||
@@ -392,13 +392,13 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
|
||||
Collection<DataNode<LibraryData>> libraryNodes =
|
||||
ExternalSystemApiUtil.findAll(projectInfo.getExternalProjectStructure(), ProjectKeys.LIBRARY);
|
||||
for (DataNode<LibraryData> libraryNode: libraryNodes) {
|
||||
String substitutionModuleCandidate = findModuleByPublication(libraryNode.getData());
|
||||
String substitutionModuleCandidate = workspace.findModule(libraryNode.getData());
|
||||
if (substitutionModuleCandidate != null) {
|
||||
toSubstitute.put(libraryNode.getData().getInternalName(), substitutionModuleCandidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Module module: getModules()) {
|
||||
ModifiableRootModel modifiableRootModel = getModifiableRootModel(module);
|
||||
|
||||
@@ -119,9 +119,9 @@ public class IdeModifiableModelsProviderImpl extends AbstractIdeModifiableModels
|
||||
|
||||
private void workspaceModelCommit() {
|
||||
ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(() -> {
|
||||
if (ExternalProjectsWorkspaceImpl.isDependencySubstitutionEnabled()) {
|
||||
updateSubstitutions();
|
||||
}
|
||||
|
||||
updateSubstitutions();
|
||||
|
||||
LibraryTable.ModifiableModel projectLibrariesModel = getModifiableProjectLibrariesModel();
|
||||
for (Map.Entry<Library, Library.ModifiableModel> entry: myModifiableLibraryModels.entrySet()) {
|
||||
Library fromLibrary = entry.getKey();
|
||||
@@ -129,10 +129,14 @@ public class IdeModifiableModelsProviderImpl extends AbstractIdeModifiableModels
|
||||
Library.ModifiableModel modifiableModel = entry.getValue();
|
||||
|
||||
// Modifiable model for the new library which was disposed via ModifiableModel.removeLibrary should also be disposed
|
||||
if (fromLibrary instanceof LibraryEx fromLibraryEx && fromLibraryEx.isDisposed()) {
|
||||
Disposer.dispose(modifiableModel);
|
||||
}
|
||||
// Modifiable model for the old library which was removed from ProjectLibraryTable should also be disposed
|
||||
if ((fromLibrary instanceof LibraryEx && ((LibraryEx)fromLibrary).isDisposed())
|
||||
|| (fromLibrary.getTable() != null && libraryName != null && projectLibrariesModel.getLibraryByName(libraryName) == null)
|
||||
|| (getModifiableWorkspace() != null && getModifiableWorkspace().isSubstituted(fromLibrary.getName()))) {
|
||||
else if (fromLibrary.getTable() != null && libraryName != null && projectLibrariesModel.getLibraryByName(libraryName) == null) {
|
||||
Disposer.dispose(modifiableModel);
|
||||
}
|
||||
else if (isSubstituted(fromLibrary.getName())) {
|
||||
Disposer.dispose(modifiableModel);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user