Skip to content

Commit

Permalink
Fix stripAuthVerApi (for now)
Browse files Browse the repository at this point in the history
Ultimately we need to rewrite all of the dependency management
to be aware of these important little details.
  • Loading branch information
ab5tract committed Oct 24, 2024
1 parent f6be6ad commit 7eaab61
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UsedModuleInspection : RakuInspection() {
val metadata = project.service<RakuMetaDataComponent>()
val moduleDetails = project.service<RakuDependencyService>()
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -233,14 +234,14 @@ class RakuMetaDataComponent(private val project: Project, val runScope: Coroutin
get() = meta?.allDepends?.toSet() ?: setOf()

val depends: List<String>
get() = meta?.depends ?: listOf()
get() = meta?.depends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf()

// More never-used functionality in Old Comma
val testDepends: List<String>
get() = meta?.testDepends ?: listOf()
get() = meta?.testDepends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf()

val buildDepends: List<String>
get() = meta?.simplifiedBuildDepends ?: listOf()
get() = meta?.simplifiedBuildDepends?.map { RakuUtils.stripAuthVerApi(it) } ?: listOf()

val providedMap: Map<String, String>
get() = meta?.provides ?: mapOf()
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/raku/comma/utils/CommaProjectUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
return if (projectHasMetaFile(project)) metaFile(project).provides.keys.map { RakuUtils.stripAuthVerApi(it) }.toSet() else setOf()
}

private val json = Json {
ignoreUnknownKeys = true
isLenient = true
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/raku/comma/utils/RakuUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7eaab61

Please sign in to comment.