Search in sources :

Example 1 with ModuleEditorImpl

use of com.google.idea.blaze.base.sync.projectstructure.ModuleEditorImpl in project intellij by bazelbuild.

the class BlazeSyncTask method updateProjectStructure.

private void updateProjectStructure(BlazeContext context, BlazeImportSettings importSettings, ProjectViewSet projectViewSet, BlazeVersionData blazeVersionData, DirectoryStructure directoryStructure, BlazeProjectData newBlazeProjectData, @Nullable BlazeProjectData oldBlazeProjectData) {
    for (BlazeSyncPlugin syncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
        syncPlugin.updateProjectSdk(project, context, projectViewSet, blazeVersionData, newBlazeProjectData);
    }
    ModuleEditorImpl moduleEditor = ModuleEditorProvider.getInstance().getModuleEditor(project, importSettings);
    ModuleType workspaceModuleType = null;
    for (BlazeSyncPlugin syncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
        workspaceModuleType = syncPlugin.getWorkspaceModuleType(newBlazeProjectData.workspaceLanguageSettings.getWorkspaceType());
        if (workspaceModuleType != null) {
            break;
        }
    }
    if (workspaceModuleType == null) {
        workspaceModuleType = ModuleType.EMPTY;
        IssueOutput.warn("Could not set module type for workspace module.").submit(context);
    }
    Module workspaceModule = moduleEditor.createModule(BlazeDataStorage.WORKSPACE_MODULE_NAME, workspaceModuleType);
    ModifiableRootModel workspaceModifiableModel = moduleEditor.editModule(workspaceModule);
    ContentEntryEditor.createContentEntries(project, workspaceRoot, projectViewSet, newBlazeProjectData, directoryStructure, workspaceModifiableModel);
    List<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, newBlazeProjectData);
    LibraryEditor.updateProjectLibraries(project, context, projectViewSet, newBlazeProjectData, libraries);
    LibraryEditor.configureDependencies(workspaceModifiableModel, libraries);
    for (BlazeSyncPlugin blazeSyncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
        blazeSyncPlugin.updateProjectStructure(project, context, workspaceRoot, projectViewSet, newBlazeProjectData, oldBlazeProjectData, moduleEditor, workspaceModule, workspaceModifiableModel);
    }
    createProjectDataDirectoryModule(moduleEditor, new File(importSettings.getProjectDataDirectory()), workspaceModuleType);
    moduleEditor.commitWithGc(context);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) ModuleType(com.intellij.openapi.module.ModuleType) ModuleEditorImpl(com.google.idea.blaze.base.sync.projectstructure.ModuleEditorImpl) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) Module(com.intellij.openapi.module.Module) File(java.io.File)

Aggregations

BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)1 ModuleEditorImpl (com.google.idea.blaze.base.sync.projectstructure.ModuleEditorImpl)1 Module (com.intellij.openapi.module.Module)1 ModuleType (com.intellij.openapi.module.ModuleType)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 File (java.io.File)1