com.intellij.openapi.module.ModifiableModuleModel Java Examples
The following examples show how to use
com.intellij.openapi.module.ModifiableModuleModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Unity3dProjectImportUtil.java From consulo-unity3d with Apache License 2.0 | 6 votes |
private static Module createAssemblyUnityScriptModuleFirstPass(Project project, ModifiableModuleModel newModel, Sdk unityBundle, MultiMap<Module, VirtualFile> virtualFilesByModule, ProgressIndicator progressIndicator, UnityProjectImportContext context) { if(isVersionHigherOrEqual(unityBundle, "2018.2")) { Module module = newModel.findModuleByName(ASSEMBLY_UNITYSCRIPT_FIRSTPASS); if(module != null) { newModel.disposeModule(module); } return null; } else { return createAndSetupModule(ASSEMBLY_UNITYSCRIPT_FIRSTPASS, project, newModel, FIRST_PASS_PATHS, unityBundle, null, "unity3d-unityscript-child", JavaScriptFileType.INSTANCE, virtualFilesByModule, progressIndicator, context); } }
Example #2
Source File: ModulePointerTest.java From consulo with Apache License 2.0 | 6 votes |
public void testDisposePointerFromUncommitedModifiableModel() throws Exception { final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "xxx"); final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel(); final Module module = modifiableModel.newModule("xxx", myProject.getBaseDir().getPath()); assertSame(pointer, ModuleUtilCore.createPointer(module)); assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "xxx")); assertSame(module, pointer.get()); assertEquals("xxx", pointer.getName()); modifiableModel.dispose(); assertNull(pointer.get()); assertEquals("xxx", pointer.getName()); }
Example #3
Source File: ModulePointerTest.java From consulo with Apache License 2.0 | 6 votes |
public void testCreateByModule() throws Exception { final Module module = addModule("x"); final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(module); assertSame(pointer, ModuleUtilCore.createPointer(module)); assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "x")); assertSame(module, pointer.get()); assertEquals("x", pointer.getName()); ModifiableModuleModel model = getModuleManager().getModifiableModel(); model.disposeModule(module); commitModel(model); assertNull(pointer.get()); assertEquals("x", pointer.getName()); final Module newModule = addModule("x"); assertSame(pointer, ModuleUtilCore.createPointer(newModule)); }
Example #4
Source File: PsiTestUtil.java From consulo with Apache License 2.0 | 6 votes |
public static Module addModule(final Project project, final String name, final VirtualFile root) { return new WriteCommandAction<Module>(project) { @Override protected void run(Result<Module> result) throws Throwable { final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel(); String moduleName = moduleModel.newModule(name, root.getPath()).getName(); moduleModel.commit(); final Module dep = ModuleManager.getInstance(project).findModuleByName(moduleName); final ModifiableRootModel model = ModuleRootManager.getInstance(dep).getModifiableModel(); final ContentEntry entry = model.addContentEntry(root); entry.addFolder(root, ProductionContentFolderTypeProvider.getInstance()); model.commit(); result.setResult(dep); } }.execute().getResultObject(); }
Example #5
Source File: FormatChangedTextUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Allows to answer if any file that belongs to the given project has changes in comparison with VCS. * * @param project target project to check * @return <code>true</code> if any file that belongs to the given project has changes in comparison with VCS * <code>false</code> otherwise */ public static boolean hasChanges(@Nonnull final Project project) { ThrowableComputable<ModifiableModuleModel,RuntimeException> action = () -> ModuleManager.getInstance(project).getModifiableModel(); final ModifiableModuleModel moduleModel = AccessRule.read(action); try { for (Module module : moduleModel.getModules()) { if (hasChanges(module)) { return true; } } return false; } finally { moduleModel.dispose(); } }
Example #6
Source File: ModifiableModelCommitter.java From consulo with Apache License 2.0 | 6 votes |
@RequiredWriteAction public static void multiCommit(ModifiableRootModel[] rootModels, ModifiableModuleModel moduleModel) { ApplicationManager.getApplication().assertWriteAccessAllowed(); final List<RootModelImpl> modelsToCommit = getSortedChangedModels(rootModels, moduleModel); final List<ModifiableRootModel> modelsToDispose = new ArrayList<ModifiableRootModel>(Arrays.asList(rootModels)); modelsToDispose.removeAll(modelsToCommit); ModuleManagerImpl.commitModelWithRunnable(moduleModel, new Runnable() { @Override public void run() { for (RootModelImpl rootModel : modelsToCommit) { rootModel.doCommitAndDispose(true); } for (ModifiableRootModel model : modelsToDispose) { model.dispose(); } } }); }
Example #7
Source File: ModuleConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@Override public void setDisplayName(String name) { name = name.trim(); final ModifiableModuleModel modifiableModuleModel = myConfigurator.getModuleModel(); if (StringUtil.isEmpty(name)) return; //empty string comes on double click on module node if (Comparing.strEqual(name, myModuleName)) return; //nothing changed try { modifiableModuleModel.renameModule(myModule, name); } catch (ModuleWithNameAlreadyExistsException ignored) { } myConfigurator.moduleRenamed(myModule, myModuleName, name); myModuleName = name; myConfigurator.setModified(!Comparing.strEqual(myModuleName, myModule.getName())); myContext.getDaemonAnalyzer().queueUpdateForAllElementsWithErrors(); }
Example #8
Source File: ModuleProjectStructureElement.java From consulo with Apache License 2.0 | 6 votes |
public void checkModulesNames(ProjectStructureProblemsHolder problemsHolder) { final ModifiableModuleModel moduleModel = myContext.getModulesConfigurator().getModuleModel(); final Module[] all = moduleModel.getModules(); if (!ArrayUtil.contains(myModule, all)) { return;//module has been deleted } for (Module each : all) { if (each != myModule && myContext.getRealName(each).equals(myContext.getRealName(myModule))) { problemsHolder.registerProblem(ProjectBundle.message("project.roots.module.duplicate.name.message"), null, ProjectStructureProblemType.error("duplicate-module-name"), createPlace(), null); break; } } }
Example #9
Source File: ModuleDeleteProvider.java From consulo with Apache License 2.0 | 6 votes |
public static void removeModule(@Nonnull final Module moduleToRemove, @Nullable ModifiableRootModel modifiableRootModelToRemove, @Nonnull Collection<ModifiableRootModel> otherModuleRootModels, @Nonnull final ModifiableModuleModel moduleModel) { // remove all dependencies on the module that is about to be removed for (final ModifiableRootModel modifiableRootModel : otherModuleRootModels) { final OrderEntry[] orderEntries = modifiableRootModel.getOrderEntries(); for (final OrderEntry orderEntry : orderEntries) { if (orderEntry instanceof ModuleOrderEntry && orderEntry.isValid()) { final Module orderEntryModule = ((ModuleOrderEntry)orderEntry).getModule(); if (orderEntryModule != null && orderEntryModule.equals(moduleToRemove)) { modifiableRootModel.removeOrderEntry(orderEntry); } } } } // destroyProcess editor if (modifiableRootModelToRemove != null) { modifiableRootModelToRemove.dispose(); } // destroyProcess module moduleModel.disposeModule(moduleToRemove); }
Example #10
Source File: Unity3dProjectImportUtil.java From consulo-unity3d with Apache License 2.0 | 6 votes |
private static Module createAssemblyCSharpModule(Project project, ModifiableModuleModel newModel, final Sdk unityBundle, MultiMap<Module, VirtualFile> virtualFilesByModule, ProgressIndicator progressIndicator, UnityProjectImportContext context) { String[] paths = {ASSETS_DIRECTORY}; return createAndSetupModule("Assembly-CSharp", project, newModel, paths, unityBundle, layer -> { if(!isVersionHigherOrEqual(unityBundle, "2018.2")) { layer.addInvalidModuleEntry(ASSEMBLY_UNITYSCRIPT_FIRSTPASS); } layer.addInvalidModuleEntry("Assembly-CSharp-firstpass"); }, "unity3d-csharp-child", CSharpFileType.INSTANCE, virtualFilesByModule, progressIndicator, context); }
Example #11
Source File: GradleToolDelegate.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Override public void processImport(Module module) { Project project = module.getProject(); File gradleFile = null; for(VirtualFile virtualFile : ModuleRootManager.getInstance(module).getContentRoots()) { File baseDir = VfsUtilCore.virtualToIoFile(virtualFile); File file = new File(baseDir, "build.gradle"); if (file.exists()) { gradleFile = file; break; } } if (gradleFile != null) { ProjectImportProvider gradleProjectImportProvider = getGradleProjectImportProvider(); ProjectImportBuilder gradleProjectImportBuilder = gradleProjectImportProvider.getBuilder(); AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), new ProjectImportProvider[]{gradleProjectImportProvider}); if (wizard.getStepCount() == 0 || wizard.showAndGet()) { gradleProjectImportBuilder.commit(project, (ModifiableModuleModel)null, (ModulesProvider)null); } } }
Example #12
Source File: ProjectFromSourcesBuilderImplModified.java From tmc-intellij with MIT License | 6 votes |
private static Module createModule( ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor, final Map<LibraryDescriptor, Library> projectLibs, final ModifiableModuleModel moduleModel) { logger.info("Starting createModule in ProjectFromSourcesBuilderImplModified"); final String moduleFilePath = descriptor.computeModuleFilePath(); ModuleBuilder.deleteModuleFile(moduleFilePath); final Module module = moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId()); final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel(); setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs); descriptor.updateModuleConfiguration(module, modifiableModel); modifiableModel.commit(); logger.info("ending createModule in ProjectFromSourcesBuilderImplModified"); return module; }
Example #13
Source File: InitializrModuleBuilder.java From intellij-spring-assistant with MIT License | 6 votes |
@NotNull @Override public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException { Module module = super.createModule(moduleModel); getApplication().invokeLater(() -> { ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { try { InitializerDownloader downloader = new InitializerDownloader(this); downloader.execute(ProgressManager.getInstance().getProgressIndicator()); } catch (IOException var2) { getApplication() .invokeLater(() -> showErrorDialog("Error: " + var2.getMessage(), "Creation Failed")); } }, "Downloading Required Files...", true, null); ModuleBuilderPostProcessor[] postProcessors = ModuleBuilderPostProcessor.EXTENSION_POINT_NAME.getExtensions(); for (ModuleBuilderPostProcessor postProcessor : postProcessors) { if (!postProcessor.postProcess(module)) { return; } } }, current()); return module; }
Example #14
Source File: RenameModuleHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean canClose(final String inputString) { final String oldName = myModule.getName(); final ModifiableModuleModel modifiableModel = renameModule(inputString); if (modifiableModel == null) return false; final Ref<Boolean> success = Ref.create(Boolean.TRUE); CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { modifiableModel.commit(); } }); } }, IdeBundle.message("command.renaming.module", oldName), null); return success.get().booleanValue(); }
Example #15
Source File: MoveModuleToGroupTopLevel.java From consulo with Apache License 2.0 | 6 votes |
private static Collection<String> getTopLevelGroupNames(final DataContext dataContext) { final Project project = dataContext.getData(CommonDataKeys.PROJECT); final ModifiableModuleModel model = dataContext.getData(LangDataKeys.MODIFIABLE_MODULE_MODEL); Module[] allModules; if ( model != null ) { allModules = model.getModules(); } else { allModules = ModuleManager.getInstance(project).getModules(); } Set<String> topLevelGroupNames = new HashSet<String>(); for (final Module child : allModules) { String[] group; if ( model != null ) { group = model.getModuleGroupPath(child); } else { group = ModuleManager.getInstance(project).getModuleGroupPath(child); } if (group != null) { topLevelGroupNames.add(group[0]); } } return topLevelGroupNames; }
Example #16
Source File: ModuleGroup.java From consulo with Apache License 2.0 | 6 votes |
public Collection<ModuleGroup> childGroups(ModifiableModuleModel model, Project project) { final Module[] allModules; if ( model != null ) { allModules = model.getModules(); } else { allModules = ModuleManager.getInstance(project).getModules(); } Set<ModuleGroup> result = new THashSet<ModuleGroup>(); for (Module module : allModules) { String[] group; if ( model != null ) { group = model.getModuleGroupPath(module); } else { group = ModuleManager.getInstance(project).getModuleGroupPath(module); } if (group == null) continue; final String[] directChild = directChild(myGroupPath, group); if (directChild != null) { result.add(new ModuleGroup(directChild)); } } return result; }
Example #17
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
public Module[] getModules() { if (myContext.myModulesConfigurator != null) { final ModifiableModuleModel model = myContext.myModulesConfigurator.getModuleModel(); return model.getModules(); } else { return myModuleManager.getModules(); } }
Example #18
Source File: ModuleElementPresentation.java From consulo with Apache License 2.0 | 5 votes |
@Override public void render(@Nonnull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { final Module module = findModule(); presentationData.setIcon(myContentFolderType.getIcon()); String moduleName; if (module != null) { moduleName = module.getName(); final ModifiableModuleModel moduleModel = myContext.getModifiableModuleModel(); if (moduleModel != null) { final String newName = moduleModel.getNewName(module); if (newName != null) { moduleName = newName; } } } else if (myModulePointer != null) { moduleName = myModulePointer.getName(); } else { moduleName = "<unknown>"; } presentationData .addText(CompilerBundle.message("node.text.0.1.compile.output", moduleName, StringUtil.toLowerCase(myContentFolderType.getName())), module != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES); }
Example #19
Source File: SandModuleImportProvider.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public void process(@Nonnull ModuleImportContext context, @Nonnull Project project, @Nonnull ModifiableModuleModel model, @Nonnull Consumer<Module> newModuleConsumer) { String path = context.getPath(); Module module = model.newModule(context.getName(), path); ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel(); modifiableModel.addContentEntry(VfsUtil.pathToUrl(path)); WriteAction.runAndWait(modifiableModel::commit); newModuleConsumer.accept(module); }
Example #20
Source File: NewOrImportModuleUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredUIAccess public static <T extends ModuleImportContext> AsyncResult<Project> importProject(@Nonnull T context, @Nonnull ModuleImportProvider<T> importProvider) { final ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx(); final String projectFilePath = context.getPath(); String projectName = context.getName(); try { File projectDir = new File(projectFilePath); FileUtil.ensureExists(projectDir); File projectConfigDir = new File(projectDir, Project.DIRECTORY_STORE_FOLDER); FileUtil.ensureExists(projectConfigDir); final Project newProject = projectManager.createProject(projectName, projectFilePath); if (newProject == null) return AsyncResult.rejected(); newProject.save(); ModifiableModuleModel modifiableModel = ModuleManager.getInstance(newProject).getModifiableModel(); importProvider.process(context, newProject, modifiableModel, module -> { }); WriteAction.runAndWait(modifiableModel::commit); newProject.save(); context.dispose(); return AsyncResult.resolved(newProject); } catch (Exception e) { context.dispose(); return AsyncResult.<Project>undefined().rejectWithThrowable(e); } }
Example #21
Source File: RenameProjectHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean canClose(final String inputString) { if (!inputString.equals(myProject.getName())) { myProject.setProjectName(inputString); myProject.save(); } if (myModule != null && !inputString.equals(myModule.getName())) { final ModifiableModuleModel modifiableModel = ModuleManager.getInstance(myProject).getModifiableModel(); try { modifiableModel.renameModule(myModule, inputString); } catch (ModuleWithNameAlreadyExistsException moduleWithNameAlreadyExists) { Messages.showErrorDialog(myProject, IdeBundle.message("error.module.already.exists", inputString), IdeBundle.message("title.rename.module")); return false; } final Ref<Boolean> success = Ref.create(Boolean.TRUE); CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { modifiableModel.commit(); } }); } }, IdeBundle.message("command.renaming.module", myModule.getName()), null); return success.get().booleanValue(); } return true; }
Example #22
Source File: NewOrImportModuleUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction @SuppressWarnings("unchecked") public static Module doCreate(@Nonnull NewProjectPanel panel, @Nonnull final ModifiableModuleModel modifiableModel, @Nonnull final VirtualFile baseDir, final boolean requireModelCommit) { NewModuleBuilderProcessor<NewModuleWizardContext> processor = panel.getProcessor(); NewModuleWizardContext context = panel.getWizardContext(); assert context != null; String name = StringUtil.notNullize(context.getName(), baseDir.getName()); Module newModule = modifiableModel.newModule(name, baseDir.getPath()); ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(newModule); ModifiableRootModel modifiableModelForModule = moduleRootManager.getModifiableModel(); ContentEntry contentEntry = modifiableModelForModule.addContentEntry(baseDir); if (context.isNewProject()) { contentEntry.addFolder(contentEntry.getUrl() + "/" + Project.DIRECTORY_STORE_FOLDER, ExcludedContentFolderTypeProvider.getInstance()); } processor.process(context, contentEntry, modifiableModelForModule); WriteAction.runAndWait(modifiableModelForModule::commit); if (requireModelCommit) { WriteAction.runAndWait(modifiableModel::commit); } baseDir.refresh(true, true); return newModule; }
Example #23
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void addModuleNode(final Module module) { final MyNode node = new MyNode(new ModuleConfigurable(myContext.myModulesConfigurator, module, TREE_UPDATER)); final TreePath selectionPath = myTree.getSelectionPath(); MyNode parent = null; if (selectionPath != null) { MyNode selected = (MyNode)selectionPath.getLastPathComponent(); final Object o = selected.getConfigurable().getEditableObject(); if (o instanceof ModuleGroup) { myContext.myModulesConfigurator.getModuleModel().setModuleGroupPath(module, ((ModuleGroup)o).getGroupPath()); parent = selected; } else if (o instanceof Module) { //create near selected final ModifiableModuleModel modifiableModuleModel = myContext.myModulesConfigurator.getModuleModel(); final String[] groupPath = modifiableModuleModel.getModuleGroupPath((Module)o); if (groupPath != null) { modifiableModuleModel.setModuleGroupPath(module, groupPath); parent = findNodeByObject(myRoot, new ModuleGroup(groupPath)); } } } if (parent == null) parent = myRoot; addNode(node, parent); ((DefaultTreeModel)myTree.getModel()).reload(parent); selectNodeInTree(node); final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer(); daemonAnalyzer.queueUpdate(new ModuleProjectStructureElement(myContext, module)); daemonAnalyzer.queueUpdateForAllElementsWithErrors(); //missing modules added }
Example #24
Source File: RenameModuleHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private ModifiableModuleModel renameModule(String inputString) { final ModifiableModuleModel modifiableModel = ModuleManager.getInstance(myProject).getModifiableModel(); try { modifiableModel.renameModule(myModule, inputString); } catch (ModuleWithNameAlreadyExistsException moduleWithNameAlreadyExists) { Messages.showErrorDialog(myProject, IdeBundle.message("error.module.already.exists", inputString), IdeBundle.message("title.rename.module")); return null; } return modifiableModel; }
Example #25
Source File: ImportModuleAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public static void executeImportAction(@Nonnull Project project, @Nullable FileChooserDescriptor descriptor) { AsyncResult<Pair<ModuleImportContext, ModuleImportProvider<ModuleImportContext>>> chooser = ModuleImportProcessor.showFileChooser(project, descriptor); chooser.doWhenDone(pair -> { ModuleImportContext context = pair.getFirst(); ModuleImportProvider<ModuleImportContext> provider = pair.getSecond(); ModifiableModuleModel modifiableModel = ModuleManager.getInstance(project).getModifiableModel(); provider.process(context, project, modifiableModel, module -> { }); WriteAction.runAndWait(modifiableModel::commit); }); }
Example #26
Source File: QuarkusModuleBuilder.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@NotNull @Override public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException { processDownload(); Module module = super.createModule(moduleModel); wizardContext.getUserData(QuarkusConstants.WIZARD_TOOL_KEY).processImport(module); return module; }
Example #27
Source File: MoveModulesToGroupAction.java From consulo with Apache License 2.0 | 5 votes |
public static void doMove(final Module[] modules, final ModuleGroup group, @Nullable final DataContext dataContext) { Project project = modules[0].getProject(); for (final Module module : modules) { ModifiableModuleModel model = dataContext != null ? dataContext.getData(LangDataKeys.MODIFIABLE_MODULE_MODEL) : null; if (model != null){ model.setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } else { ModuleManagerImpl.getInstanceImpl(project).setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } } AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane(); if (pane != null) { pane.updateFromRoot(true); } if (!ProjectSettingsService.getInstance(project).processModulesMoved(modules, group) && pane != null) { if (group != null) { pane.selectModuleGroup(group, true); } else { pane.selectModule(modules[0], true); } } }
Example #28
Source File: ModulePointerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testRenameModule() throws Exception { final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "abc"); final Module module = addModule("abc"); ModifiableModuleModel model = getModuleManager().getModifiableModel(); model.renameModule(module, "xyz"); commitModel(model); assertSame(module, pointer.get()); assertEquals("xyz", pointer.getName()); }
Example #29
Source File: FlutterModuleBuilder.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void addAndroidModule(@NotNull Project project, @Nullable ModifiableModuleModel model, @NotNull String baseDirPath, @NotNull String flutterModuleName) { final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(baseDirPath); if (baseDir == null) { return; } final VirtualFile androidFile = findAndroidModuleFile(baseDir, flutterModuleName); if (androidFile == null) return; try { final ModifiableModuleModel toCommit; if (model == null) { toCommit = ModuleManager.getInstance(project).getModifiableModel(); //noinspection AssignmentToMethodParameter model = toCommit; } else { toCommit = null; } model.loadModule(androidFile.getPath()); if (toCommit != null) { WriteAction.run(toCommit::commit); } } catch (ModuleWithNameAlreadyExists | IOException e) { FlutterUtils.warn(LOG, e); } }
Example #30
Source File: ModifiableModelCommitter.java From consulo with Apache License 2.0 | 5 votes |
private static List<RootModelImpl> getSortedChangedModels(ModifiableRootModel[] _rootModels, final ModifiableModuleModel moduleModel) { List<RootModelImpl> rootModels = new ArrayList<RootModelImpl>(); for (ModifiableRootModel _rootModel : _rootModels) { RootModelImpl rootModel = (RootModelImpl)_rootModel; if (rootModel.isChanged()) { rootModels.add(rootModel); } } sortRootModels(rootModels, moduleModel); return rootModels; }