diff --git a/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileImpl.kt b/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileImpl.kt index 3bb4eef9a98d..eb8fcab56149 100644 --- a/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileImpl.kt +++ b/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileImpl.kt @@ -85,28 +85,28 @@ private class CompositeGroupProvider : InspectionGroupProvider { } @Internal -class YamlInspectionProfileImpl private constructor(override val profileName: String?, - override val inspectionToolsSupplier: InspectionToolsSupplier, - override val inspectionProfileManager: BaseInspectionProfileManager, - override val baseProfile: InspectionProfileImpl, - override val configurations: List, - override val groups: List, - private val groupProvider: InspectionGroupProvider) : YamlInspectionProfile, InspectionGroupProvider { - +class YamlInspectionProfileImpl private constructor( + override val profileName: String?, + override val inspectionToolsSupplier: InspectionToolsSupplier, + override val inspectionProfileManager: BaseInspectionProfileManager, + override val baseProfile: InspectionProfileImpl, + override val configurations: List, + override val groups: List, + private val groupProvider: InspectionGroupProvider, +) : YamlInspectionProfile, InspectionGroupProvider { companion object { @JvmStatic - fun loadFrom(reader: Reader, - includeReaders: (Path) -> Reader, - toolsSupplier: InspectionToolsSupplier, - profileManager: BaseInspectionProfileManager + fun loadFromYamlRaw( + yaml: YamlInspectionProfileRaw, + baseProfile: InspectionProfileImpl, + toolsSupplier: InspectionToolsSupplier, + profileManager: BaseInspectionProfileManager ): YamlInspectionProfileImpl { - val profile = readConfig(reader, includeReaders) - val baseProfile = findBaseProfile(profileManager, profile.baseProfile) - val configurations = profile.inspections.map(::createInspectionConfig) + val configurations = yaml.inspections.map(::createInspectionConfig) val groupProvider = CompositeGroupProvider() 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 groupMap = groups.associateBy { group -> group.groupId } override fun findGroup(groupId: String): YamlInspectionGroup? { @@ -116,7 +116,7 @@ class YamlInspectionProfileImpl private constructor(override val profileName: St groupProvider.addProvider(customGroupProvider) return YamlInspectionProfileImpl( - profile.name, + yaml.name, toolsSupplier, profileManager, baseProfile, @@ -125,6 +125,17 @@ class YamlInspectionProfileImpl private constructor(override val profileName: St 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 fun loadFrom(project: Project, filePath: String = "${getDefaultProfileDirectory(project)}/profile.yaml", diff --git a/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileRaw.kt b/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileRaw.kt index 5e037553c673..03e6607c4b30 100644 --- a/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileRaw.kt +++ b/platform/inspect/src/com/intellij/codeInspection/inspectionProfile/YamlInspectionProfileRaw.kt @@ -2,12 +2,14 @@ package com.intellij.codeInspection.inspectionProfile import com.intellij.codeInspection.inspectionProfile.YamlProfileUtils.makeYaml +import org.jetbrains.annotations.ApiStatus import org.yaml.snakeyaml.Yaml import java.io.Reader import java.nio.file.Path import java.nio.file.Paths -internal class YamlInspectionProfileRaw( +@ApiStatus.Internal +class YamlInspectionProfileRaw( val baseProfile: String? = null, val name: String? = null, val groups: List = emptyList(), @@ -19,13 +21,15 @@ internal class YamlInspectionProfileRaw( } } -internal class YamlInspectionGroupRaw( +@ApiStatus.Internal +class YamlInspectionGroupRaw( val groupId: String = "Unknown", val inspections: List = emptyList(), val groups: List = emptyList() ) -internal class YamlInspectionConfigRaw( +@ApiStatus.Internal +class YamlInspectionConfigRaw( val inspection: String? = null, val group: String? = null, val enabled: Boolean? = null,