mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
move call JdkAuto to InspectionConfiguration step
GitOrigin-RevId: 814955cf64bf2bba14c7f3fcf5c6aa534a0a7af3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f517c8a50b
commit
8bd7dcca66
@@ -1,6 +1,8 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.ide.CommandLineInspectionProgressReporter;
|
||||
import com.intellij.ide.CommandLineInspectionProjectConfigurator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.intellij.conversion.ConversionListener;
|
||||
import com.intellij.conversion.ConversionService;
|
||||
import com.intellij.diff.tools.util.text.LineOffsetsUtil;
|
||||
import com.intellij.diff.util.Range;
|
||||
import com.intellij.ide.CommandLineInspectionProgressReporter;
|
||||
import com.intellij.ide.CommandLineInspectionProjectConfigurator;
|
||||
import com.intellij.ide.impl.PatchProjectUtil;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
|
||||
@@ -45,5 +45,6 @@
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics" />
|
||||
<orderEntry type="module" module-name="intellij.platform.inspect" scope="RUNTIME" />
|
||||
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.projectRoots.impl
|
||||
|
||||
import com.intellij.analysis.AnalysisScope
|
||||
import com.intellij.ide.CommandLineInspectionProgressReporter
|
||||
import com.intellij.ide.CommandLineInspectionProjectConfigurator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.nio.file.Path
|
||||
|
||||
class SdkConfigurator : CommandLineInspectionProjectConfigurator {
|
||||
override fun isApplicable(projectPath: Path, logger: CommandLineInspectionProgressReporter): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun configureProject(project: Project,
|
||||
scope: AnalysisScope,
|
||||
logger: CommandLineInspectionProgressReporter) {
|
||||
runBlocking {
|
||||
resolveUnknownSdks(project, ProgressManager.getInstance().progressIndicator)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.projectRoots.impl
|
||||
|
||||
import com.intellij.openapi.application.invokeAndWaitIfNeeded
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ui.configuration.UnknownSdk
|
||||
import com.intellij.openapi.roots.ui.configuration.UnknownSdkResolver
|
||||
import kotlin.coroutines.resume
|
||||
import kotlinx.coroutines.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
private val LOG: Logger = Logger.getInstance(SdkConfigurator::class.java)
|
||||
|
||||
internal suspend fun resolveUnknownSdks(project: Project, indicator: ProgressIndicator) {
|
||||
val problems = suspendCancellableCoroutine<List<UnknownSdk>> { cont ->
|
||||
UnknownSdkCollector(project).collectSdksPromise(Consumer { (_, resolvableSdks) ->
|
||||
cont.resume(resolvableSdks)
|
||||
})
|
||||
}
|
||||
|
||||
val resolvers = UnknownSdkResolver.EP_NAME.extensions.mapNotNull {
|
||||
it.createResolver(project, indicator)
|
||||
}
|
||||
|
||||
for (problem in problems) {
|
||||
resolveUnknownSdk(resolvers, problem, indicator, project)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun resolveUnknownSdk(resolvers: List<UnknownSdkResolver.UnknownSdkLookup>,
|
||||
problem: UnknownSdk,
|
||||
indicator: ProgressIndicator,
|
||||
project: Project) {
|
||||
val localFix = resolvers.asSequence().mapNotNull { it.proposeLocalFix(problem, indicator) }.firstOrNull()
|
||||
if (localFix != null) {
|
||||
LOG.info("Found local fix for $problem: ${localFix.existingSdkHome} (${localFix.versionString})")
|
||||
suspendCancellableCoroutine<Unit> { cont ->
|
||||
invokeAndWaitIfNeeded {
|
||||
UnknownSdkTracker.configureLocalSdk(problem, localFix, com.intellij.util.Consumer { cont.resume(Unit) })
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val remoteFix = resolvers.asSequence().mapNotNull { it.proposeDownload(problem, indicator) }.firstOrNull()
|
||||
if (remoteFix != null) {
|
||||
LOG.info("Found remote fix for $problem: ${remoteFix.downloadDescription} (${remoteFix.versionString})")
|
||||
suspendCancellableCoroutine<Unit> { cont ->
|
||||
invokeAndWaitIfNeeded {
|
||||
UnknownSdkTracker.downloadFix(project, problem, remoteFix, com.intellij.util.Consumer {},
|
||||
com.intellij.util.Consumer { cont.resume(Unit) })
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
LOG.warn("No SDK found for $problem")
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection;
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection;
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -588,7 +588,7 @@
|
||||
<extensionPoint name="implementationViewDocumentFactory" interface="com.intellij.codeInsight.hint.ImplementationViewDocumentFactory" dynamic="true"/>
|
||||
|
||||
<extensionPoint name="highlightInfoPostFilter" interface="com.intellij.codeInsight.daemon.impl.HighlightInfoPostFilter" area="IDEA_PROJECT" dynamic="true"/>
|
||||
<extensionPoint name="commandLineInspectionProjectConfigurator" interface="com.intellij.codeInspection.CommandLineInspectionProjectConfigurator" dynamic="true"/>
|
||||
<extensionPoint name="commandLineInspectionProjectConfigurator" interface="com.intellij.ide.CommandLineInspectionProjectConfigurator" dynamic="true"/>
|
||||
|
||||
<extensionPoint name="fileTypeStatisticProvider" interface="com.intellij.internal.statistic.fileTypes.FileTypeStatisticProvider" dynamic="true"/>
|
||||
<extensionPoint name="lang.directNavigationProvider" dynamic="true" interface="com.intellij.navigation.DirectNavigationProvider"/>
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
serviceImplementation="com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl"/>
|
||||
|
||||
<postStartupActivity implementation="com.intellij.openapi.projectRoots.impl.UnknownSdkStartupChecker"/>
|
||||
<commandLineInspectionProjectConfigurator implementation="com.intellij.openapi.projectRoots.impl.SdkConfigurator"/>
|
||||
<registryKey key="unknown.sdk" defaultValue="true" description="Check for unknown SDKs and provide automatic fixes or smart suggestions"/>
|
||||
<registryKey key="unknown.sdk.show.editor.actions" defaultValue="true" description="Show editor suggestions to fix missing SKDs"/>
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package org.jetbrains.plugins.gradle
|
||||
|
||||
import com.intellij.analysis.AnalysisScope
|
||||
import com.intellij.codeInspection.CommandLineInspectionProgressReporter
|
||||
import com.intellij.codeInspection.CommandLineInspectionProjectConfigurator
|
||||
import com.intellij.ide.CommandLineInspectionProgressReporter
|
||||
import com.intellij.ide.CommandLineInspectionProjectConfigurator
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
||||
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode.MODAL_SYNC
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInspection.CommandLineInspectionProgressReporter;
|
||||
import com.intellij.codeInspection.CommandLineInspectionProjectConfigurator;
|
||||
import com.intellij.ide.CommandLineInspectionProgressReporter;
|
||||
import com.intellij.ide.CommandLineInspectionProjectConfigurator;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
|
||||
Reference in New Issue
Block a user