diff --git a/src/main/java/org/raku/comma/inspection/inspections/UsedModuleInspection.kt b/src/main/java/org/raku/comma/inspection/inspections/UsedModuleInspection.kt index 7136968f..4fad1882 100644 --- a/src/main/java/org/raku/comma/inspection/inspections/UsedModuleInspection.kt +++ b/src/main/java/org/raku/comma/inspection/inspections/UsedModuleInspection.kt @@ -36,7 +36,7 @@ class UsedModuleInspection : RakuInspection() { val metadata = project.service() val moduleDetails = project.service() if (moduleDetails.isNotInitialized) { - if (! metadata.providedNames.contains(moduleName)) { + if (! CommaProjectUtil.projectProvides(project).contains(moduleName)) { holder.registerProblem(element, DESCRIPTION_META6_FORMAT.format(moduleName), ProblemHighlightType.WARNING) } return diff --git a/src/main/java/org/raku/comma/services/project/RakuMetaDataComponent.kt b/src/main/java/org/raku/comma/services/project/RakuMetaDataComponent.kt index b706d57b..2fb558a8 100644 --- a/src/main/java/org/raku/comma/services/project/RakuMetaDataComponent.kt +++ b/src/main/java/org/raku/comma/services/project/RakuMetaDataComponent.kt @@ -32,6 +32,7 @@ import kotlinx.serialization.json.Json import org.json.JSONArray import org.raku.comma.RakuIcons import org.raku.comma.metadata.data.MetaFile +import org.raku.comma.utils.RakuUtils import java.io.IOException import java.nio.charset.StandardCharsets import java.nio.file.Path @@ -233,14 +234,14 @@ class RakuMetaDataComponent(private val project: Project, val runScope: Coroutin get() = meta?.allDepends?.toSet() ?: setOf() val depends: List - get() = meta?.depends ?: listOf() + get() = meta?.depends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf() // More never-used functionality in Old Comma val testDepends: List - get() = meta?.testDepends ?: listOf() + get() = meta?.testDepends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf() val buildDepends: List - get() = meta?.simplifiedBuildDepends ?: listOf() + get() = meta?.simplifiedBuildDepends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf() val providedMap: Map get() = meta?.provides ?: mapOf() diff --git a/src/main/java/org/raku/comma/utils/CommaProjectUtil.kt b/src/main/java/org/raku/comma/utils/CommaProjectUtil.kt index 88620eee..0a4d651b 100644 --- a/src/main/java/org/raku/comma/utils/CommaProjectUtil.kt +++ b/src/main/java/org/raku/comma/utils/CommaProjectUtil.kt @@ -34,6 +34,11 @@ object CommaProjectUtil { return if (projectHasMetaFile(project)) metaFile(project).depends.map { RakuUtils.stripAuthVerApi(it) } else listOf() } + @JvmStatic + fun projectProvides(project: Project): Set { + return if (projectHasMetaFile(project)) metaFile(project).provides.keys.map { RakuUtils.stripAuthVerApi(it) }.toSet() else setOf() + } + private val json = Json { ignoreUnknownKeys = true isLenient = true diff --git a/src/main/java/org/raku/comma/utils/RakuUtils.java b/src/main/java/org/raku/comma/utils/RakuUtils.java index c5348d0c..6b604451 100644 --- a/src/main/java/org/raku/comma/utils/RakuUtils.java +++ b/src/main/java/org/raku/comma/utils/RakuUtils.java @@ -113,7 +113,7 @@ public static String escapeHTML(String str) { } public static String stripAuthVerApi(String name) { - Pattern patten = Pattern.compile("(.+)((:ver|:auth|:api)(<.+>|\\(.+\\)))+"); + Pattern patten = Pattern.compile("(.+)((:ver|:auth|:api)(<(.*:).+>|\\(.+\\)))+"); Matcher matcher = patten.matcher(name); if (matcher.matches()) { return matcher.group(1);