softwareCobbler / luceedebug

line debugger for lucee
GNU Lesser General Public License v2.1
44 stars 15 forks source link

Support Multiple `pathTransform` Mappings #14

Closed jamiejackson closed 1 year ago

jamiejackson commented 1 year ago

I think I need multiple pathTransforms.

I think (because I'm new to vs code) I want a multi-root workspace as follows:

Since I bake the Mura core into my image, it's not available in my_site_cfml. I have Mura checked out separately.

I'd want something like:

"pathTransform": [
  {
    "idePrefix": "${workspaceFolder}/cfml/deployment_root",
    "cfPrefix": "/var/www"
  },
  {
    // not sure the most semantic way to specify this path in vs code, but this would probably work
    "idePrefix": "${workspaceFolder}/../hudx_mura_fork/app/core",
    "cfPrefix": "/var/www/wwwroot/core/"
  },
]

I could probably work around it with symlinks or something, but it would be good to have native support.

It might get a little tricky because layering would need to be accommodated. (It would probably make sense to have increasing precedent as you append to the pathTransform array.

softwareCobbler commented 1 year ago

(huh didn't mean to close)

This is now pathTransforms (plural), but the syntax is as you show it - a JSON array literal. It can be of length 0, 1, or many. The first matching prefix wins. If no match is found, no transform takes place.

softwareCobbler commented 1 year ago

I don't know how it'll play with a multiroot workspace, I think a debug launch config is per workspace, so ${workspaceRoot} is always a single value. It would seem natural for it to find files across both workspaces, assuming it's being given absolute paths.

jamiejackson commented 1 year ago

Thanks! I'll try it out in the next few days.

jamiejackson commented 1 year ago

I haven't tried it with multiple mappings yet but I have verified that a single mapping does work inside of the new array structure. PR to fix up the docs and references: #15

I'll report back when I've verified the behavior of multiple mappings.

jamiejackson commented 1 year ago

@softwareCobbler , could you describe how precedence works when multiple (potentially "nested") mappings are specified? I looked at the new munging code but it wasn't obvious how it worked, from a quick read-through.

jamiejackson commented 1 year ago

Good news, the multiple pathTransforms seems to be working!

Regarding precedence: This order works:

"pathTransforms": [
    {
        "idePrefix": "/Users/jjackson/projects/hudx/hudx_mura_fork/app/core",
        "cfPrefix": "/var/www/wwwroot/core"
    },
    {
        "idePrefix": "${workspaceFolder}/cfml/deployment_root",
        "cfPrefix": "/var/www"
    },
]

The reverse order doesn't work. It says the file doesn't exist and asks if I want to add it. For example, if I set a breakpoint in /Users/jjackson/projects/hudx/hudx_mura_fork/app/core/mura/content/contentServer.cfc, it wants to create a file in /Users/jjackson/projects/hudx/hudx/cfml/deployment_root/wwwroot/core/mura/content/contentServer.cfc.

In other words, the lower the array index (i.e., physically higher in the config file), the higher the precedence. Is that what you had in mind? My brain works the opposite way but that's probably just subjective.

Regardless of how it shakes out, I can send a documentation PR on it, if you'd like.

jamiejackson commented 1 year ago

Never mind, I just reread your comments:

The first matching prefix wins.

That's what we've got already, so I'll send a documentation PR.

jamiejackson commented 1 year ago

Added documentation to #15.

jamiejackson commented 1 year ago

I don't know how it'll play with a multiroot workspace, I think a debug launch config is per workspace, so ${workspaceRoot} is always a single value. It would seem natural for it to find files across both workspaces, assuming it's being given absolute paths.

I found the ${workspaceFolder:my_folder_name} syntax in the VS code docs. It's working well, so far. I like that it (along with the hudx.code-workspace workspace definition) is portable, so my team can use it from SCM without needing personal versions.

"configurations": [
    {
        "type": "cfml",
        "request": "attach",
        "name": "Debug HUDX Lucee",
        "hostName": "local.hudx.net",
        "port": 10000,
        "pathTransforms": [
            {
                "idePrefix": "${workspaceFolder:mura}/app/core",
                "cfPrefix": "/var/www/wwwroot/core"
            },
            {
                "idePrefix": "${workspaceFolder:hudx}/cfml/deployment_root",
                "cfPrefix": "/var/www"
            },
        ]
    }
]

I may end up documenting this, too.