mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IJPL-162718 cleanup
GitOrigin-RevId: 615377bb04f43e515306d583ddf2701fc8aae674
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0776107c38
commit
86b2d9ecc9
@@ -7,7 +7,6 @@ import com.intellij.ide.impl.NewProjectUtil.createFromWizard
|
||||
import com.intellij.ide.impl.NewProjectUtil.setCompilerOutputPath
|
||||
import com.intellij.ide.impl.OpenProjectTask.Companion.build
|
||||
import com.intellij.ide.impl.ProjectUtil.focusProjectWindow
|
||||
import com.intellij.ide.impl.ProjectUtil.getOpenProjects
|
||||
import com.intellij.ide.impl.ProjectUtil.isSameProject
|
||||
import com.intellij.ide.impl.ProjectUtil.updateLastProjectLocation
|
||||
import com.intellij.ide.projectWizard.NewProjectWizardCollector
|
||||
@@ -42,11 +41,11 @@ import com.intellij.util.TimeoutUtil
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.concurrent.CancellationException
|
||||
|
||||
private val LOG = logger<NewProjectUtil>()
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
internal suspend fun createNewProjectAsync(wizard: AbstractProjectWizard) {
|
||||
// warm-up components
|
||||
serviceAsync<ProjectManager>().defaultProject
|
||||
@@ -71,6 +70,7 @@ object NewProjectUtil {
|
||||
createNewProject(wizard)
|
||||
}
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
@JvmStatic
|
||||
fun createNewProject(wizard: AbstractProjectWizard) {
|
||||
// warm-up components
|
||||
@@ -102,18 +102,17 @@ object NewProjectUtil {
|
||||
}
|
||||
|
||||
fun setCompilerOutputPath(project: Project, path: String) {
|
||||
val extension = CompilerProjectExtension.getInstance(project) ?: return
|
||||
CommandProcessor.getInstance().executeCommand(project, {
|
||||
val canonicalPath = try {
|
||||
FileUtil.resolveShortWindowsName(path)
|
||||
}
|
||||
catch (_: IOException) {
|
||||
path
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
val extension = CompilerProjectExtension.getInstance(project)
|
||||
if (extension != null) {
|
||||
val canonicalPath = try {
|
||||
FileUtil.resolveShortWindowsName(path)
|
||||
}
|
||||
catch (_: IOException) {
|
||||
path
|
||||
}
|
||||
extension.compilerOutputUrl = VfsUtilCore.pathToUrl(canonicalPath)
|
||||
}
|
||||
extension.compilerOutputUrl = VfsUtilCore.pathToUrl(canonicalPath)
|
||||
}
|
||||
}, null, null)
|
||||
}
|
||||
@@ -128,18 +127,20 @@ object NewProjectUtil {
|
||||
|
||||
private fun doCreate(wizard: AbstractProjectWizard, projectToClose: Project?): Project? {
|
||||
val projectFilePath = wizard.newProjectFilePath
|
||||
for (p in getOpenProjects()) {
|
||||
if (isSameProject(Paths.get(projectFilePath), p)) {
|
||||
focusProjectWindow(p, false)
|
||||
val projectManager = ProjectManagerEx.getInstanceEx()
|
||||
|
||||
val projectFile = Path.of(projectFilePath)
|
||||
|
||||
for (p in ProjectUtilCore.getOpenProjects()) {
|
||||
if (isSameProject(projectFile, p)) {
|
||||
focusProjectWindow(project = p, stealFocusIfAppInactive = false)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val projectBuilder = wizard.projectBuilder
|
||||
LOG.debug { "builder $projectBuilder" }
|
||||
val projectManager = ProjectManagerEx.getInstanceEx()
|
||||
try {
|
||||
val projectFile = Path.of(projectFilePath)
|
||||
val projectDir = if (wizard.storageScheme == StorageScheme.DEFAULT) {
|
||||
projectFile.parent ?: throw IOException("Cannot create project in '$projectFilePath': no parent file exists")
|
||||
}
|
||||
@@ -176,7 +177,7 @@ private fun doCreate(wizard: AbstractProjectWizard, projectToClose: Project?): P
|
||||
val compileOutput = wizard.newCompileOutput
|
||||
setCompilerOutputPath(newProject, compileOutput)
|
||||
if (projectBuilder != null) {
|
||||
// validate can require project on disk
|
||||
// validate can require a project on disk
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode) {
|
||||
newProject.save()
|
||||
}
|
||||
@@ -215,7 +216,7 @@ private fun doCreate(wizard: AbstractProjectWizard, projectToClose: Project?): P
|
||||
if (newProject !== projectToClose) {
|
||||
updateLastProjectLocation(projectFile)
|
||||
val moduleConfigurator = projectBuilder.createModuleConfigurator()
|
||||
val options = OpenProjectTask {
|
||||
val options = OpenProjectTask {
|
||||
project = newProject
|
||||
projectName = projectFile.fileName.toString()
|
||||
callback = ProjectOpenedCallback { openedProject, module ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.projectWizard;
|
||||
|
||||
import com.intellij.ide.actions.ImportModuleAction;
|
||||
@@ -127,10 +127,6 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
return myCreatedProject;
|
||||
}
|
||||
|
||||
protected Project getCreatedProject() {
|
||||
return myCreatedProject;
|
||||
}
|
||||
|
||||
private Module createModuleFromWizard(@NotNull Project project) {
|
||||
Module createdModule = new NewModuleAction().createModuleFromWizard(project, null, myWizard);
|
||||
waitForConfiguration(project);
|
||||
@@ -161,10 +157,6 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
adjuster.accept(npwStep);
|
||||
}
|
||||
|
||||
protected void cancelWizardRun() {
|
||||
throw new CancelWizardException();
|
||||
}
|
||||
|
||||
private static class CancelWizardException extends RuntimeException {
|
||||
}
|
||||
|
||||
@@ -193,9 +185,10 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
}
|
||||
}
|
||||
|
||||
protected void createWizard(@Nullable Project project) throws IOException {
|
||||
protected void createWizard(@Nullable Project project) {
|
||||
setWizard(createWizard(project, contentRoot));
|
||||
UIUtil.dispatchAllInvocationEvents(); // to make default selection applied
|
||||
// to make default selection applied
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
protected Project createProject(Consumer<? super Step> adjuster) throws IOException {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.ide.highlighter.ProjectFileType
|
||||
import com.intellij.openapi.application.*
|
||||
import com.intellij.openapi.components.ComponentManagerEx
|
||||
import com.intellij.openapi.components.StorageScheme
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.debug
|
||||
import com.intellij.openapi.fileChooser.impl.FileChooserUtil
|
||||
@@ -176,7 +177,7 @@ object ProjectUtil {
|
||||
}
|
||||
if (ProjectUtilCore.isValidProjectPath(file)) {
|
||||
// see OpenProjectTest.`open valid existing project dir with inability to attach using OpenFileAction` test about why `runConfigurators = true` is specified here
|
||||
return ProjectManagerEx.getInstanceEx().openProjectAsync(file, options.copy(runConfigurators = true))
|
||||
return (serviceAsync<ProjectManager>() as ProjectManagerEx).openProjectAsync(file, options.copy(runConfigurators = true))
|
||||
}
|
||||
|
||||
if (!options.preventIprLookup && Files.isDirectory(file)) {
|
||||
@@ -192,7 +193,7 @@ object ProjectUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ignore: IOException) {
|
||||
catch (_: IOException) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +217,7 @@ object ProjectUtil {
|
||||
|
||||
val project: Project?
|
||||
if (processors.size == 1 && processors[0] is PlatformProjectOpenProcessor) {
|
||||
project = ProjectManagerEx.getInstanceEx().openProjectAsync(
|
||||
project = (serviceAsync<ProjectManager>() as ProjectManagerEx).openProjectAsync(
|
||||
projectStoreBaseDir = file,
|
||||
options = options.copy(
|
||||
isNewProject = true,
|
||||
@@ -433,7 +434,7 @@ object ProjectUtil {
|
||||
return try {
|
||||
Files.isSameFile(projectFile, existingBaseDirPath)
|
||||
}
|
||||
catch (ignore: IOException) {
|
||||
catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -442,7 +443,7 @@ object ProjectUtil {
|
||||
return try {
|
||||
Files.isSameFile(projectFile, projectStore.projectFilePath)
|
||||
}
|
||||
catch (ignore: IOException) {
|
||||
catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -613,7 +614,7 @@ object ProjectUtil {
|
||||
|
||||
private suspend fun openOrCreateProjectInner(name: String, file: Path): Project? {
|
||||
val existingFile = if (isProjectFile(file)) file else null
|
||||
val projectManager = ProjectManagerEx.getInstanceEx()
|
||||
val projectManager = serviceAsync<ProjectManager>() as ProjectManagerEx
|
||||
if (existingFile != null) {
|
||||
for (p in projectManager.openProjects) {
|
||||
if (isSameProject(existingFile, p)) {
|
||||
@@ -629,7 +630,7 @@ object ProjectUtil {
|
||||
!Files.exists(file) && Files.createDirectories(file) != null || Files.isDirectory(file)
|
||||
}
|
||||
}
|
||||
catch (e: IOException) {
|
||||
catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -692,13 +693,13 @@ object ProjectUtil {
|
||||
val preferAttach = currentProject != null &&
|
||||
canAttach &&
|
||||
(PlatformUtils.isDataGrip() && !ProjectUtilCore.isValidProjectPath(file))
|
||||
if (preferAttach && attachToProjectAsync(projectToClose = currentProject!!, projectDir = file, callback = null)) {
|
||||
if (preferAttach && attachToProjectAsync(projectToClose = currentProject, projectDir = file, callback = null)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val project = if (canAttach) {
|
||||
val options = createOptionsToOpenDotIdeaOrCreateNewIfNotExists(file, currentProject)
|
||||
ProjectManagerEx.getInstanceEx().openProjectAsync(file, options)
|
||||
(serviceAsync<ProjectManager>() as ProjectManagerEx).openProjectAsync(file, options)
|
||||
}
|
||||
else {
|
||||
openOrImportAsync(file, OpenProjectTask().withProjectToClose(currentProject))
|
||||
|
||||
Reference in New Issue
Block a user