Quiet[$Context = newi @ "$Context", {LinkObject::linkv}]
where newi
appears to be a symbol that'll look like <ContextBeingSwitchedTo>`Private`SavedContextInfo
. I'm not sure we already have something similar, but I'm working on more code inspections for the IntelliJ plugin and it's always a good idea to ask the community. Since it doesn't really fit on main, I'm posting it here on Meta.
Linting is an excellent way to point the developer to probable erro...
Dynamic
and set up a few different forms of link snooping to try to figure it out. Internal`DynamicEvaluate
just magically knows the notebook it's being called from. Like I thought other two arguments were to tell it where the content was being evaluated, but it turns out the FE handles all of that instead and preemptively switches the kernel context. IntelliJListener`linkDrain[link_] := If[LinkConnectedQ[link] && LinkReadyQ[link], Flatten@ Reap[ While[LinkReadyQ[link], Sow@LinkReadHeld[link] ] ][[2]], $Failed ]; IntelliJListener`intelliJREPL[link_] := Replace[IntelliJListener`linkDrain[link], { EvaluatePacket[response_] :> LinkWrite[link, ReturnPacket[response]] }, 1 ]; IntelliJListener`startIntelliJListener[link_LinkObject] := If[$VersionNumber < 11.1, RunScheduledTask,
linkDrain[link_] := If[LinkConnectedQ@link, Replace[ Reap[ While[LinkReadyQ[link], Sow@LinkRead[link]] ][[2]] // Flatten, ReturnPacket[e_] :> e, 1 ], $Failed ]; linkSubmit[link_, expr_] := LinkWrite[link, Unevaluated@EvaluatePacket[expr]]; linkSubmit~SetAttributes~HoldRest launchFrontEnd[innerKernel_, name_: "IntelliJ"] := Block[{$ContextPath = {"System`"}}, LinkWrite[ innerKernel, Unevaluated@ EvaluatePacket[ << SubprocessKernel`; SubprocessKernel`$SubprocessKernelName = name;
"Local"
. So I changed up the package to create a partial $UserBaseDirectory
in the $TemporaryDirectory
which the FE initializes from.