justarandomgeek / vscode-factoriomod-debug

Factorio Mod Tool Kit
Other
97 stars 21 forks source link

How can I configure this adapter to work with source files? #82

Open mkaulfers opened 1 year ago

mkaulfers commented 1 year ago

I have a TypeScriptToLua transpiler package I'm working on, and I'd love to get this working with it such that I can breakpoint/step through original source code. Is this a flag that I can set in a configuration? For more context, feel free to look at my current source code for the package I'm attempting to set it up on.

www.github.com/mkaulfers/create-typed-factorio.

With the current setup, I'm able to set breakpoints within the lua files themselves, and have been toying around with enabling the map files for translation. So far, unsuccessful.

justarandomgeek commented 1 year ago

Unfortunately, it's not quite that simple.

I looked into reading the TS sourcemaps before but there's a few problems:

  1. Sourcemaps assume all locations have a column. Lua doesn't have column information at all. This by itself would be relatively minor, except it severely exacerbates the next problem.
  2. The sourcemaps TStoLua produces are completely lacking mappings for many output lines, which seems to be invalid based on the way the sourcemap library behaved when attempting to map through them (i forget now whether it throws or just returns null, but it's impractical to deal with).
  3. DAP frequently wants to convert the line/column/path information individually, which seems to be completely incompatible with sourcemaps needing it to always map as a complete "location", when combined with the differing location-styles.

But it's been a while since I tried to hook this up, so when i finish my current pipe reworks i'll see if they've fixed any of that...

mkaulfers commented 1 year ago

You know, there could be some "Hacky" things that could be done with it. Perhaps wrapping the entry point with some function then sends it back to the debugger if an exception occurs. If you get around to checking it out, I'd love to help. I have some capacity for working on Open Source projects, and this is one I'd be keen to help with.