recognizer
recognizer copied to clipboard
Coffeescript support
Hi, I think your extsnion is really good and useful, but sadly I use CoffeeScript. Could you add CoffeeScript support some day ?
Hi. CoffeeScript support is definitely something I would like to add as I prefer CoffeeScript too. However, do not expect CoffeeScript support anytime soon. There are so many things on the roadmap that have higher priority and are also easier to do.
For the moment I am very busy but some time i'll try to send PR.
I am sorry for being stupid, but I don't know it works. Could you quickly explain in a 2 lines please?
I'm sorry, I probably won't fit this into 2 lines. The code is not stable yet and any kind of API is entirely missing. :/
In short, Recognizer reads JavaScript code from every file which is open (i.e. in a working set) in Brackets. Each file is instrumented separately using Instrumenter.js
. It works like this:
- Source is parsed and converted to AST using esprima
- esprima also keeps original position of every node in AST
- AST is then recursively traversed and modified to include log statements
- escodegen then regenerates new code from the instrumented AST and replaces the original
- a tracer snippet (tracer.js) is added to each file, which contains a unique identifier and definitions of all log functions
- using TracerManager.js I connect to each tracer (each files has one) and regularly poll it for all saved logs
CoffeeScript support is difficult for various reasons. You need to create an AST of CoffeeScript code. Each node in AST has to know its location in the original code. This is quite difficult, since CoffeeScript needs to be first compiled to JavaScript. AST then contains location of expressions in a JavaScript file. You would need to find way how to convert it back to CoffeeScript source, probably using source maps (but this still isn't 1:1 conversion and you would have to make).
OK thank you very much I will take a, look a this!
After some research CoffeescriptRedux can return an AST tree with line numbers. Example
foo()
will give
{
"body": {
"statements": [{
"function": {
"data": "foo",
"line": 1,
"column": 1,
"offset": 0,
"raw": "foo"
},
"arguments": [],
"raw": "foo()",
"line": 1,
"column": 1,
"offset": 0
}],
"line": 1,
"column": 1,
"offset": 0,
"raw": "foo()"
},
"line": 1,
"column": 1,
"offset": 0,
"raw": "foo()"
}
Thanks, I wasn't aware of this. This could make CoffeeScript support significantly easier.
The only problem is that the AST tree given by CoffeescriptRedux and by esprima might not be structured equally.
I was wondering, where does it detect the value of a var
?
In var foo = bar;
only the right side is instrumented (var foo = logProbe(bar);
) for now. Is that what you meant?
No in which file in which funtion
In TracedDocument.js
in updateProbeValues
I call a JavaScript runtime and retrieve the values of all probes in the file. The result is passed to insertProbes
where I create the markers and tooltips one by one.
Thank you very much!
How's it going here? I would love to see CoffeeScript support!
I can't run recognizer, I get [Recognizer] Error connecting to tracer in main.js
@Vinz243 I've just pushed the latest version to the Registry, could you please try it again?
It isnt in the registry, I just forked recognizer, then cloned it and add it (symlink) into the bracket extension folder (user). I am on win 7 32