mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[qodana] QD-10859 qodana yaml profile section supports profile.yaml syntax
(cherry picked from commit d784db2c51ac3e3dc84c32fda54cc774816a24d7) IJ-CR-156429 GitOrigin-RevId: 8a38559c56b168d5da6b2e371c2eed70d0e17ee2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
18f567d5a3
commit
5bc7a0c95f
@@ -85,28 +85,28 @@ private class CompositeGroupProvider : InspectionGroupProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
class YamlInspectionProfileImpl private constructor(override val profileName: String?,
|
class YamlInspectionProfileImpl private constructor(
|
||||||
override val inspectionToolsSupplier: InspectionToolsSupplier,
|
override val profileName: String?,
|
||||||
override val inspectionProfileManager: BaseInspectionProfileManager,
|
override val inspectionToolsSupplier: InspectionToolsSupplier,
|
||||||
override val baseProfile: InspectionProfileImpl,
|
override val inspectionProfileManager: BaseInspectionProfileManager,
|
||||||
override val configurations: List<YamlBaseConfig>,
|
override val baseProfile: InspectionProfileImpl,
|
||||||
override val groups: List<YamlInspectionGroup>,
|
override val configurations: List<YamlBaseConfig>,
|
||||||
private val groupProvider: InspectionGroupProvider) : YamlInspectionProfile, InspectionGroupProvider {
|
override val groups: List<YamlInspectionGroup>,
|
||||||
|
private val groupProvider: InspectionGroupProvider,
|
||||||
|
) : YamlInspectionProfile, InspectionGroupProvider {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun loadFrom(reader: Reader,
|
fun loadFromYamlRaw(
|
||||||
includeReaders: (Path) -> Reader,
|
yaml: YamlInspectionProfileRaw,
|
||||||
toolsSupplier: InspectionToolsSupplier,
|
baseProfile: InspectionProfileImpl,
|
||||||
profileManager: BaseInspectionProfileManager
|
toolsSupplier: InspectionToolsSupplier,
|
||||||
|
profileManager: BaseInspectionProfileManager
|
||||||
): YamlInspectionProfileImpl {
|
): YamlInspectionProfileImpl {
|
||||||
val profile = readConfig(reader, includeReaders)
|
val configurations = yaml.inspections.map(::createInspectionConfig)
|
||||||
val baseProfile = findBaseProfile(profileManager, profile.baseProfile)
|
|
||||||
val configurations = profile.inspections.map(::createInspectionConfig)
|
|
||||||
val groupProvider = CompositeGroupProvider()
|
val groupProvider = CompositeGroupProvider()
|
||||||
groupProvider.addProvider(InspectionGroupProviderEP.createDynamicGroupProvider())
|
groupProvider.addProvider(InspectionGroupProviderEP.createDynamicGroupProvider())
|
||||||
|
|
||||||
val groups = profile.groups.map { group -> createGroup(groupProvider, group) }
|
val groups = yaml.groups.map { group -> createGroup(groupProvider, group) }
|
||||||
val customGroupProvider = object : InspectionGroupProvider {
|
val customGroupProvider = object : InspectionGroupProvider {
|
||||||
val groupMap = groups.associateBy { group -> group.groupId }
|
val groupMap = groups.associateBy { group -> group.groupId }
|
||||||
override fun findGroup(groupId: String): YamlInspectionGroup? {
|
override fun findGroup(groupId: String): YamlInspectionGroup? {
|
||||||
@@ -116,7 +116,7 @@ class YamlInspectionProfileImpl private constructor(override val profileName: St
|
|||||||
groupProvider.addProvider(customGroupProvider)
|
groupProvider.addProvider(customGroupProvider)
|
||||||
|
|
||||||
return YamlInspectionProfileImpl(
|
return YamlInspectionProfileImpl(
|
||||||
profile.name,
|
yaml.name,
|
||||||
toolsSupplier,
|
toolsSupplier,
|
||||||
profileManager,
|
profileManager,
|
||||||
baseProfile,
|
baseProfile,
|
||||||
@@ -125,6 +125,17 @@ class YamlInspectionProfileImpl private constructor(override val profileName: St
|
|||||||
groupProvider)
|
groupProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun loadFrom(reader: Reader,
|
||||||
|
includeReaders: (Path) -> Reader,
|
||||||
|
toolsSupplier: InspectionToolsSupplier,
|
||||||
|
profileManager: BaseInspectionProfileManager
|
||||||
|
): YamlInspectionProfileImpl {
|
||||||
|
val profile = readConfig(reader, includeReaders)
|
||||||
|
val baseProfile = findBaseProfile(profileManager, profile.baseProfile)
|
||||||
|
return loadFromYamlRaw(profile, baseProfile, toolsSupplier, profileManager)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun loadFrom(project: Project,
|
fun loadFrom(project: Project,
|
||||||
filePath: String = "${getDefaultProfileDirectory(project)}/profile.yaml",
|
filePath: String = "${getDefaultProfileDirectory(project)}/profile.yaml",
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
package com.intellij.codeInspection.inspectionProfile
|
package com.intellij.codeInspection.inspectionProfile
|
||||||
|
|
||||||
import com.intellij.codeInspection.inspectionProfile.YamlProfileUtils.makeYaml
|
import com.intellij.codeInspection.inspectionProfile.YamlProfileUtils.makeYaml
|
||||||
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import org.yaml.snakeyaml.Yaml
|
import org.yaml.snakeyaml.Yaml
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
internal class YamlInspectionProfileRaw(
|
@ApiStatus.Internal
|
||||||
|
class YamlInspectionProfileRaw(
|
||||||
val baseProfile: String? = null,
|
val baseProfile: String? = null,
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
val groups: List<YamlInspectionGroupRaw> = emptyList(),
|
val groups: List<YamlInspectionGroupRaw> = emptyList(),
|
||||||
@@ -19,13 +21,15 @@ internal class YamlInspectionProfileRaw(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class YamlInspectionGroupRaw(
|
@ApiStatus.Internal
|
||||||
|
class YamlInspectionGroupRaw(
|
||||||
val groupId: String = "Unknown",
|
val groupId: String = "Unknown",
|
||||||
val inspections: List<String> = emptyList(),
|
val inspections: List<String> = emptyList(),
|
||||||
val groups: List<String> = emptyList()
|
val groups: List<String> = emptyList()
|
||||||
)
|
)
|
||||||
|
|
||||||
internal class YamlInspectionConfigRaw(
|
@ApiStatus.Internal
|
||||||
|
class YamlInspectionConfigRaw(
|
||||||
val inspection: String? = null,
|
val inspection: String? = null,
|
||||||
val group: String? = null,
|
val group: String? = null,
|
||||||
val enabled: Boolean? = null,
|
val enabled: Boolean? = null,
|
||||||
|
|||||||
Reference in New Issue
Block a user