question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extend `customToolReplacesArgs` to allow replacing all tool args

See original GitHub issue

This is not working as I expect based on the prior information in this issue. I have created a brand new dart project, a simple cli app. For my launch config, I first tried this:

        {
            "name": "toolTest",
            "request": "launch",
            "type": "dart",
            "program": "bin/main.dart",
            "customTool": "echo",
        }

Output: --enable-asserts --enable-vm-service=0 --pause_isolates_on_start=true --no-serve-devtools --write-service-info=file:///var/folders/h0/y0mhxm317slfr5k149cfxvfr0000gn/T/dart-vm-service-7630.json -DSILENT_OBSERVATORY=true bin/main.dart

So far so good. I then tried to see if I could remove args:

        {
            "name": "toolTest",
            "request": "launch",
            "type": "dart",
            "program": "bin/main.dart",
            "customTool": "echo",
            "customToolReplacesArgs": 2,
        }

Output: --enable-asserts --enable-vm-service=0 --pause_isolates_on_start=true --no-serve-devtools --write-service-info=file:///var/folders/h0/y0mhxm317slfr5k149cfxvfr0000gn/T/dart-vm-service-6a28.json -DSILENT_OBSERVATORY=true bin/main.dart

Hmm, that’s odd. Nothing got removed. Maybe it need tool args to replace them?

        {
            "name": "toolTest",
            "request": "launch",
            "type": "dart",
            "program": "bin/main.dart",
            "customTool": "echo",
            "customToolReplacesArgs": 2,
            "toolArgs": [
                "test",
                "arg"
            ]
        }

Output: test arg --enable-asserts --enable-vm-service=0 --pause_isolates_on_start=true --no-serve-devtools --write-service-info=file:///var/folders/h0/y0mhxm317slfr5k149cfxvfr0000gn/T/dart-vm-service-6280.json -DSILENT_OBSERVATORY=true bin/main.dart

So it appears that “echo” replaces “dart” as the tool but customToolReplacesArgs maybe does nothing?

        {
            "name": "toolTest",
            "request": "launch",
            "type": "dart",
            "program": "bin/main.dart",
            "customTool": "echo",
            "toolArgs": [
                "test",
                "arg"
            ]
        }

Output: test arg --enable-asserts --enable-vm-service=0 --pause_isolates_on_start=true --no-serve-devtools --write-service-info=file:///var/folders/h0/y0mhxm317slfr5k149cfxvfr0000gn/T/dart-vm-service-19d2.json -DSILENT_OBSERVATORY=true bin/main.dart

Same thing. How do I get the arg replacement to work?

Additionally, if I try this with a flutter project, it completely ignores “customTool” and continues running as normal even though I’m using the exact same launch config. How does the extension determine whether it’s a flutter project or not and why does it ignore the customTool arg?

_Originally posted by @point-source in https://github.com/Dart-Code/Dart-Code/issues/3656#issuecomment-1002830930_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Jan 5, 2022

@point-source yeah, that had crossed my mind recently too, but I don’t want this to get too complicated without a solid use case/example. Generally if you want to put a tool in place of Dart/Flutter, it should be very compatible with them, so the best thing is for them to implement the same interface.

The changes made above were a fairly simple extension of existing behaviour that’s necessary for internal Bazel workspaces and I think will solve most use cases (even if you have to set the number high to remove everything, then just add things back in toolArgs), but if you have a concrete use where this isn’t sufficient please do file a new issue with the details.

Dart-Code will soon move over to an SDK-shipped debug adapter, which means functionality like this needs to be also implemented there, and will be shared by other editors too (and thus becomes harder to change, as we need to consider compatibility) so there will likely be a higher bar for implementing things than when the debug adapter just lived here (and could be changed at the same time as the only editor using it).

0reactions
point-sourcecommented, Jan 4, 2022

DanTup,

Thanks for taking a look and working on this so quickly. To be clear, my use case doesn’t necessarily need that specific functionality. I was mostly just trying to conceptualize the operation of the tool so I had my head wrapped around it and could use it in a predictable manner going forward. In my tests, I was not able to figure out what it did.

That said, the changes you made appear to extend functionality in a useful way. My only concern is that it is still rather opaque in what it is doing. I know this was mentioned in the original feature request and the conclusion was that using documentation and the “echo” tool, one could discover the operation.

I just wanted to throw it out there that we could perhaps just do an exclude list of args rather than a iteration based removal. That way, even though discovery remains opaque, the implementation on the config side is explicit and users can see exactly which args are being removed. This also solves the position problem.

Something like:

"excludeArgs": [
    "--start-paused"
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code extension updates - v3.34 - Google Groups
Hi all,. New versions of the VS Code extensions for Dart/Flutter have ... launching apps) can now be used to replace all tool...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found