kenkangxgwe / lsp-wl

A Wolfram Language Server
MIT License
214 stars 22 forks source link

Feature Request: Provide a debugger for vscode #5

Closed minkir014 closed 3 years ago

minkir014 commented 5 years ago

This extension is very good but it needs a debugger to be completed.

kenkangxgwe commented 5 years ago

Hi @minkir014 , we have looked into both Debug Adaptor Protocol (DAP) and Mathematica debugger in the Frontend, but neither of them is easy to start with. we will leave this as an open discussion and hope there will be a solution someday in the future.

minkir014 commented 5 years ago

You can you use Mathematica already existing debugger and start with the debug protocol.

minkir014 commented 5 years ago

Do you know if we can debug wolfram can be debugged on gdb like MATLAB?

kenkangxgwe commented 5 years ago

AFAIK, this won't be easy. The debugger is from the Frontend package, they need GUI to set the breakpoints and so on. There is no text-based debugger and the related functions are not documented.

minkir014 commented 5 years ago

I know it isn't easy but we have to start and not be afraid. Secondly, you don't need to make a GUI you have vscode GUI you only have to connect vscode Debug API to that package so they work together to make a great debugger.

kenkangxgwe commented 5 years ago

We may not prioritize this at the moment. I'm working on something more important for the next release that may eventually helpful for debugging. But, you are right, I won't give it up.

minkir014 commented 5 years ago

I know it'll take time but I can help you. First, Can you send me the link of the debugger package. I can't get alone without Wolfram branch. Send me the link so that I can help you.

minkir014 commented 5 years ago

@kenkangxgwe please send me the link as fast as you can.

kenkangxgwe commented 5 years ago

There is no such an isolated package (or link if you insist), you may only access to it from inside the Mathematica. It is GeneralUtilities`Debugging`. If you type Names["GeneralUtilities`Debugging`*`*"], you may see all the functions and variables in that package.

minkir014 commented 5 years ago

Ok, I'll begin working on the debugger but I'll need some. So, stay with me in communication.

minkir014 commented 5 years ago

Does your extension includes error detection?

minkir014 commented 5 years ago

@kenkangxgwe Are you here???

kenkangxgwe commented 5 years ago

Yes, we leverage the GeneralUtilities`Packages`PackagePrivate`findFileSyntaxErrors to reveal the errors. But the types of errors and warnings it can find is limited. I will consider enhancing it some day. I am not able to always be online recently, so please feel free to leave messages here. I will response to them ASAP.

minkir014 commented 5 years ago

OK, thanks for response. One thing, have you noticed that there isn't any debugger for wolfram. The debugger wolfram branch provides is for matlab?

kenkangxgwe commented 5 years ago

image As I said, there is a GUI debugger, but I am not sure if you may access it w/o the FrontEnd.

minkir014 commented 5 years ago

This isn't for .wl and .wls files. It's for mathematica only.

kenkangxgwe commented 5 years ago

You may debug the .wl and .wls files as well inside Mathematica. The debugger is not extracted from the FrontEnd. The best thing I can think of is to find the function for the GUI debugger and imitate it to implement a non-FE based debugger.

kenkangxgwe commented 5 years ago

Some references that might help you if you want to mimic the Mathematica debugger:

minkir014 commented 5 years ago

I partially understood how mathematica debugger works. It sends commands to the terminal and tells it if to compile or stop at line and uses its inspect to show variables. We could use vs code debugging APIs for that. Second, we must make a wolfram debugger for MATLAB and that wouldn't be hard because there is a language server for MATLAB and the debugger is ready. The only thing we will have to do is to allow breakpoints for MATLAB and this is very easy.

kenkangxgwe commented 5 years ago

Sorry, but how is the wolfram debugger related to MATLAB, could you please elaborate?

minkir014 commented 5 years ago

See this video on wolfram own website and you'll understand. http://www.wolfram.com/broadcast/video.php?c=93&v=890

kenkangxgwe commented 5 years ago

OK, what you showed is the Wolfram Workbench, a commercial plugin for Eclipse. But how is it related to MATLAB?

minkir014 commented 5 years ago

I know it's wolfram workbench. And about how it is related to MATLAB. Have you seen the debugged file extension. It's .m.

kenkangxgwe commented 5 years ago

.m extension is not only for MATLAB, but it may also indicate a wolfram package (alternative to .wl) or a Objective-C file.

minkir014 commented 5 years ago

You are right. The syntax is for Wolfram not for MATLAB. I didn't take care of that.

minkir014 commented 5 years ago

About error detection there are two packages called AST and Lint. They can help you. See this link https://mathematica.stackexchange.com/a/192690

minkir014 commented 5 years ago

See you can use Lint and preview the result in the problems part in vs code.

kenkangxgwe commented 3 years ago

Hi @minkir014 , Thanks for opening this issue and I think your feature request is partially fulfilled by v0.3.0 after 2 yrs. I'd like to close this issue and continue improving on the existing debugging feature. Glad you mentioned the two packages which helped this project a lot.