Skip to content

Commit

Permalink
Add loading of core libraries in the same way as dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ab5tract committed Oct 25, 2024
1 parent 7eaab61 commit cdb2030
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RakudoImplementationDetailInspection : RakuInspection() {
val resolution = reference.resolve()
if (excludeCall(element.callName, resolution)) {
holder.registerProblem(element,
DESCRIPTION_FORMAT_METHOD.format(element.callName),
DESCRIPTION_FORMAT_METHOD.format(element.callName, "method"),
ProblemHighlightType.INFORMATION)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class UndeclaredOrDeprecatedRoutineInspection : RakuInspection() {

// Only do the analysis if the core setting symbols are available.
// TODO!!! Get the CoreSettings stuff extracted working again.
val setting = element.getProject().service<RakuProjectSdkService>().symbolCache?.getCoreSettingFile()
val setting = element.getProject().service<RakuProjectSdkService>().symbolCache.getCoreSettingFile()
?: return
if (setting.virtualFile.name == "DUMMY") return

// Resolve the reference.
val subName = element.callName
if (subName == "::") return
if (subName.startsWith("::")) return
val reference = element.reference as PsiReferenceBase.Poly<*> ?: return
val results = reference.multiResolve(true)

Expand Down Expand Up @@ -52,7 +52,8 @@ class UndeclaredOrDeprecatedRoutineInspection : RakuInspection() {

private fun RakuSubCallName.isValidNqp(): Boolean {
if (! this.callName.startsWith("nqp::")) return false
return PsiTreeUtil.findChildrenOfType(containingFile, RakuUseStatement::class.java).any { it.moduleName == "nqp" }
return PsiTreeUtil.findChildrenOfType(containingFile, RakuUseStatement::class.java)
.any { it.moduleName == "nqp" || it.moduleName == "MONKEY-GUTS" }
|| this.project.service<RakuProjectDetailsService>().isProjectRakudoCore()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public class RakuServiceConstants {
"NativeCall::Types",
"NativeCall::Compiler::GNU",
"NativeCall::Compiler::MSVC",
"Test", "Pod::To::Text", "Telemetry"
"Test",
"Pod::To::Text",
"Telemetry"
);

public static final List<String> PRAGMAS = List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DependencyDetails(private val project: Project, private val runScope: Coro
// This should *only* be called by the RakuDependencyService.doInitialize()
fun dependenciesToRakuFiles(state: ModuleDetailsState): Deferred<ModuleDetailsState> {
if (project.service<RakuProjectSdkService>().zef == null) return CompletableDeferred(state)

return runScope.async {
fillProvidesToRakuFiles(state)
}
Expand Down Expand Up @@ -111,6 +112,16 @@ class DependencyDetails(private val project: Project, private val runScope: Coro
// TODO: Do something with the notInstalled details
val result = Json.decodeFromString<PathLookupResult>(output)
provideMap.putAll(result.pathLookup)

val coreLocateScript = RakuUtils.getResourceAsFile("scripts/find-core-provided-libraries.raku")
?: throw ExecutionException("Resource bundle is corrupted: locate script is missing")
val corePathCollectorScript = RakuCommandLine(sdkHome)
corePathCollectorScript.addParameter(coreLocateScript.absolutePath)
output = corePathCollectorScript.executeAndRead(null).joinToString("\n")
// TODO: Do something with the notInstalled details
val coreResult = Json.decodeFromString<PathLookupResult>(output)
provideMap.putAll(coreResult.pathLookup)

return@future provideMap
} catch (e: Exception) {
RakuSdkUtil.reactToSdkIssue(project, "Cannot use current Raku SDK ${e.message!!}")
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/scripts/find-core-provided-libraries.raku
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

use JSON::Fast;

sub MAIN() {
my $repo = CompUnit::RepositoryRegistry.repository-for-name("core");

my %path-lookup = |$repo.installed.map(-> $d {
$d.meta<provides>.kv.map(-> $k,$v {
$k => [ $d.content($v.keys.head).IO.absolute ]
})
}).flat;

say to-json
%(
pathLookup => %path-lookup,
notInstalled => []
);
}

0 comments on commit cdb2030

Please sign in to comment.