Skip to content

Commit

Permalink
Use $project-name.iml as the module root config...
Browse files Browse the repository at this point in the history
... when opening old projects

This has been working well for the generated projects,
so with any luck this will fix issue #3 (:crossed-fingers:)
  • Loading branch information
ab5tract committed Sep 24, 2024
1 parent eb2ee98 commit e940a5c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/org/raku/comma/project/RakuProjectBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.raku.comma.project;

import com.intellij.ide.highlighter.ModuleFileType;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.ide.util.projectWizard.WizardContext;
Expand Down Expand Up @@ -29,6 +30,7 @@
import org.raku.comma.services.RakuSDKService;

import javax.swing.*;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -68,6 +70,13 @@ public boolean isSuitableSdkType(SdkTypeId sdkType) {
return sdkType instanceof RakuSdkType;
}

private String getModuleFilePath(Project project) {
return "%s%s%s%s".formatted(project.getBasePath(),
File.separator,
project.getName(),
ModuleFileType.DOT_DEFAULT_EXTENSION);
}

@Nullable
@Override
public List<Module> commit(@NotNull Project project,
Expand All @@ -86,14 +95,11 @@ public List<Module> commit(@NotNull Project project,
VirtualFile contentRoot = lfs.findFileByPath(path.substring(5));
if (contentRoot == null) return;

String projectFilePath = project.getProjectFilePath();
if (projectFilePath == null) return;

ModifiableModuleModel modelToPatch = model != null
? model
: ModuleManager.getInstance(project).getModifiableModel();

Module module = modelToPatch.newModule(projectFilePath, RakuModuleType.getInstance().getId());
Module module = modelToPatch.newModule(getModuleFilePath(project), RakuModuleType.getInstance().getId());
result.add(module);

ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
Expand Down

0 comments on commit e940a5c

Please sign in to comment.