:: Article Deprecated!

:: As of v1.1, F4 looks in pods for source code.

:: Article Deprecated!

F4 Logo When writing code it can be huge boost to the view source code of any 3rd party libraries (pods) you're using. It clarifies what's going, shows you the developers intent, and the comments can be helpful.

When using F4 by Xored, not only is the source code a single mouse click (or F3 key press) away, but you can also step through it when debugging! Awesome!

But by default it only works with system pods and any projects F4 has open. - sadness -

Until now! - happiness! -

All Alien-Factory pods are compiled with debug information and bundled with source code. To let F4 gain access to this, all you need to do is copy the source files from the pod into your Fantom home directory. Or more specifically, to the pod's src dir in the Fantom home directory.

Taking the afIoc.pod as an example, if you open it up as a .zip file:

Inspecting afIoc.pod as a .zip file

You will see the usual pod directories. If you copy the contents of src/ to %FAN_HOME%\src\afIoc\ then F4 will be able to pick it up.

Source Code Install Script

If all this file copying seems like too much manual effort, then try this handy Fantom script instead:

select all
using util

class InstallSrc : AbstractMain {

    @Arg Str? pod
    @Opt Bool uninstall

    override Int run() {
        pod     := Pod.find(pod)
        podDir  := Env.cur.homeDir.plus(`src/${pod.name}/`).normalize
        echo("Found ${pod.name} v${pod.version}")

        if (uninstall) {
            echo("Deleting '${podDir.osPath}'")
            return 0

        // copy src to %FAN_HOME% for F4 debugging
        echo("Copying ${pod.name} src to '${podDir.osPath}'")
        podDir.delete    // delete old stuff

        fileCnt := 0
        podFile := Env.cur.findPodFile(pod.name)
        zip     := Zip.open(podFile)
        zip.contents.each |file| {
            if (file.pathStr.startsWith("/src/")) {
        echo("Copied ${fileCnt} files")

        return 0

Assuming you've saved it as a file named InstallSrc.fan, you can use it like this:

C:\>fan InstallSrc.fan afIoc

Found afIoc v1.6.0
Copying afIoc src to 'C:\Apps\fantom-1.0.66\src\afIoc'
Copied 69 files

And to remove the source code:

C:\>fan InstallSrc.fan afIoc -uninstall

Found afIoc v1.6.0
Deleting 'C:\Apps\fantom-1.0.66\src\afIoc'

Have fun!


See also Xored F4: Debugging a Pod with Source Code.


  • 18 Aug 2016 - Deprecated.