Visual Studio Code Extension Variable - plugins

Does anyone know if it's possible to write an extension in Visual Studio code that can write the values in the variables window to a file after each step while in debug mode. So, a step would happen, the variable would get written to a file, another step would happen, and the next set of variables would be written. Is there anything like this out there? Can it even be done?
Here's what I have so far:
1) I created an extension in VS code, and will write my functionality in the following provided method:
function activate(context) {
let disposable = vscode.commands.registerCommand('extension.helloWorld', function () {
// Display a message box to the user
vscode.window.showInformationMessage('Hello World!');
});
2) There are some variables offered here that could be relevant (such as debugger), but they throw errors when I use them.
To explain more clearly, what I would like to do is the following: create an extension in VS code that when used launches another instance of VS code (as does every extension), and within this new instance, load a user program, debug the program step by step, and write the variables at each step of the user program to a file. This main reason for even making the extension is the last step, as VS Code doesn't have any built in functionality to do anything like this that I know of. One issue is I am not sure the 'debugger' variable in the extension (or any variables) refer to the new instance, and if there is a way to do this.
If there is a better and smarter approach, I would love to hear it.
Thank you very much everyone in advance

Related

VS code Dlang: can't change build config

I am giving D a shot with the VS code extension code-d. Everything works fine, except that I can't switch configuration, arch type or build type. If I try to do any of these things, I receive the following output message in code-d & serve-d:
{"code":-32602,"data":null,"message":"`params` MUST be an object (named arguments) or array (positional arguments), other types are not allowed by spec"}
At this point, I only have a hello world project, as described in the code-d documentation. Am I missing something?
There is a workaround for this. You can use user tasks in vs code. Create user tasks in vs code for each of your build configuration. Then install this extension (https://github.com/actboy168/vscode-tasks). This will pick each of your task and display it in the task bar of vs code. So you only need a mouse click.

how to run/view the output of a subsection of code in eclipse (beginner)

I am a complete beginner in java/eclipse/programming. I want to test small parts of my code to see if they are functioning in the way I want them to.
It is not intuitive to me from my first impressions of the program if/how I can run subsections of code. I also haven't yet found the answer to this problem online.
1) In eclipse, is it possible to highlight a couple of lines of code and view the output they would produce in the console?
2) If so, what are the step by step instructions to do this?
EDIT: I am running eclipse 4.7.0
Create a .jpage Scrapbook page (see Eclipse help: Creating a Java Scrapbook Page):
(via https://twitter.com/EclipseJavaIDE/status/882560433588240384)
The best way to do this is to keep your code modular or in other words make sure the different parts of your code are different functions. This way its simple to just run each function individually from your main function. In Java the main function is required so everything that you want to run has to somehow be triggered from whats in your main function.
Example in pseudo code:
some function{
code you want to run
}
other function{
other code you want to run
}
main function{
some function()
otherfunction()
}

Visual Studio Code User Defined Argument

I'm working with visual studio code tasks and can define arguments in a task successfully upfront as follows:
{"version":"0.1.0","command":"example","isShellCommand":true,"tasks":
[{"taskName":"example task","suppressTaskName":true,"args":["examplearg"]}]}
I would like to be able to type in the argument when running the task, as the argument needs to be user defined, is that possible? For example I would like to be able to Run Task from command pallete: example task --myCustomArg.
Not possible. Open an issue in their repo and see what they say.
There is, however, a way to pass the current file. See here.
Your last choice would be to create an extension. You should give it a try as well. 😊

hierarchy of functions in MatLab

I have been reading someone else's matlab code and I don't know how the code structured. I mean I would like to know the hierarchy of functions, which function uses which function. I am reading the code to figure that out but its taking a lot of time.
So is there any other way I can see this hierarchy without reading the whole thing? To be honest it is starting to get confusing. Maybe MatLab has a built in function for that! I found this:
How can I generate a list of function dependencies in MATLAB?
but this doesn't seem to be helpful!
The MATLAB profiler will show you what functions are called by your code (and much more information to boot) and allow you to click through the hierarchy of function calls. You can either call profile on and then run your code, then call profile off and profile viewer, or you can simply call profile viewer and type a single line of code to run in the edit box at the top.
Use the dependency report provided in MATLAB:
http://www.mathworks.co.uk/help/matlab/matlab_prog/identify-dependencies.html
There are also some tools on the File Exchange, such as fdep.
No idea about a function to show visible or depended-upon functions. However the basic rules are:
1) Only the first function in a .m file (normally has to have the same name as the file itself) is visible outside that file.
2) Any function can see any top level (see 1.) function if the file is in the matlab path. Matlab can show you the path so you know where it's hunting.
3) The order of the path is important, the first instance of a function called foo found in the path will be called. Obviously the current directory is at the top of the path.
3) All functions in a given file can see all other functions in that file.
That's the basics. No doubt there are other rules, and possibly exceptions to this. But that understanding generally serves me well.
Obviously the easiest way to work out which function is being called is to click on it in the editor and open it.
One thing I do is simply place in each function at the beginning fprintf("inside function <name>/n"); and at the end of the function fprintf("leaving function <name>/n"); where <name> is the name of the function.
This will give you a very specific list of which function is being called by which function (based on the order that they appear). Another thing like this would be to place fprintf("function <name1> calling function <name2>/n"); so you can be more explicit about which function is being called by which one.

Comment Template variables in Eclipse

I have a comment template in Eclipse (CDT) that I use for function calls which looks like:
//****************************************************************************
//
// Function: ${enclosing_method}
//
// Purpose:
//
// Parameters:
//
//****************************************************************************
My problem is that the ${enclosing_method} template variable doesn't work MOST of the time, but other times it does and I have yet to figure out why. I've tried using the comment template inside of the function and outside (on top of) the function definition even within the same header file. I prefer it to be on top and have seen it work in that position but again I don't know why.
What prerequisites need to be met in order for the enclosing_method variable to place the name within the comment automagically?
Thanks in advance for any insight you can provide.
You are not the only one experiencing issues with this template.
Even in JDT (Java) there is a problem, since 2004! See bug 76661.
It is however not entirely reproducible.
Looked into this to try and find a reproducible case. I can get it happen consistently if I add a new method to a class and then execute the template inside of the method before saving
So far, no patch in sight.