[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [orion-dev] Try out a new outline view for Javascript
|
For this:
x = window.addEventListener('load', function(event) {}, false);
Mark: load(event),
Nonymous-design: x<(load-fal) (more about this another time)
and this:
addEventListener('load', function(event) {}, false);
Mark: load(event)
Nonymous-design: // addEventListener(load-fals)
It looks like you observed these results while still using Orion's default JSLint outliner. (Check your plugins and make sure jslintPlugin is gone -- I have a note in the
README about how to get rid of it.)
The result from the the Outliner plugin on Github is:
function(event)
... for both cases, which is bad. I considered using JSLint's approach, but decided not to --- while it works nicely in some cases (eg. addEventListener), I think it assumes too much about your function signatures.
Since you mention define(), I should point out that for this code:
define(['dojo','setup'], function(dojo, mSetup) {});
Outliner gives you this for the function label, which doesn't mention "define" anywhere:
function(dojo, mSetup)
I like the FOC approach of including the invoked function name (addEventListener) as well as the other arguments to it ("load") to give context to the anonymous function.
The notation did confuse me, though...
Mark
John J Barton ---09/07/2011 12:57:39 AM---I made good progress based on Mark's plugin: https://github.com/johnjbarton/outliner
From: John J Barton <johnjbarton@xxxxxxxxxxxxxxx>
To: Orion developer discussions <orion-dev@xxxxxxxxxxx>
Date: 09/07/2011 12:57 AM
Subject: Re: [orion-dev] Try out a new outline view for _javascript_
Sent by: orion-dev-bounces@xxxxxxxxxxx
I made good progress based on Mark's plugin: https://github.com/johnjbarton/outliner
I renamed uglifoc to Nonymous: https://github.com/johnjbarton/nonymous
Right off I can see this plugin will be great for me at least: I found two bugs and two design issues in the first 5 minutes ;-).
Bugs: I fail on define() and one of the assignment test cases.
Design:
x = window.addEventListener('load', function(event) {}, false);
// x<(load-fal)
addEventListener('load', function(event) {}, false);
// addEventListener(load-fals);
x = window.addEventListener('load', function(event) {}, false);
Mark: load(event),
Nonymous-design: x<(load-fal) (more about this another time)
// x<(load-fal)
// x<(load-fal)
addEventListener('load', function(event) {}, false);
Mark: load(event)
Nonymous-design: // addEventListener(load-fals)
I'd like to know the reasoning on the Mark result. It's not bad in this case, except for the duplication issue.
In the Nonymous names the parenthesis do *not* mean function args. I think that is bad design. We were not thinking about showing the arguments after function names the way the outliner does. We use the parens to mean "in a function argument", so addEventListener(load-fals) is code for "a function defn in an argument to addEventListener with other arguments "load" and "fals" (cut off by our clipper).
If we add arguments and open up the clipper we could get:
addEventListener(load-false)(event)
but that seems like it will lead to confusion. Plus pretty soon you have the entire line of source ;-). Needs work.
On another front, building up plugins from github projects:
I'm not to keen on the way my fork ends up in terms of file layout. Mark has lib/UglifyJs and lib/transformjs, so I added lib/nonymous. That part seems good, but my tree also has UglifyJS, so we end up with:
lib/nonymous/UglifyJS and
lib/UglifyJS
in the plugin source tree. Beyond being ugly (heh), this can combine with path and package arguments to require.js to leave us confused about which version of UglifyJS is in play. If anyone has any experience or has seen other ways to do this please let me know.
jjb
On Fri, Sep 2, 2011 at 2:05 PM, John Arthorne <John_Arthorne@xxxxxxxxxx> wrote:
Mark, I tried this out and I have to say it's a vast improvement on the jslint outline already! Don't forget to add license/copyright headers to your js files... this might be something we want to eventually consume back.
Better heuristics on names would be fantastic so I can't wait to see jjb's fork.
That would be very cool!
I've split it into https://github.com/mamacdon/outliner
Mark
John J Barton ---09/01/2011 12:08:47 PM---Any chance you would consider breaking out your plugin into a new github repro? Then I could fork it
From: John J Barton <johnjbarton@xxxxxxxxxxxxxxx>
To: Orion developer discussions <orion-dev@xxxxxxxxxxx>
Date: 09/01/2011 12:08 PM
Subject: Re: [orion-dev] Try out a new outline view for _javascript_
Sent by: orion-dev-bounces@xxxxxxxxxxx
Any chance you would consider breaking out your plugin into a new github repro? Then I could fork it and incorporate uglifoc,
https://github.com/johnjbarton/uglifoc
which has a more elaborate heuristic for names based on the work of Salman Mirghasemi.
jjb
On Thu, Sep 1, 2011 at 8:40 AM, Mark MacDonald <Mark_MacDonald@xxxxxxxxxx> wrote:
Recently I've been experimenting with UglifyJS's parse-js library [1] for building _javascript_ syntax trees. I've used it to provide a version of the outline view that shows your _javascript_ functions in a tree, rather than the flat list we currently get from JSLint.
It's packaged as an Orion plugin, which you can try out like this:
1. Make sure you're running an Orion build from 08/29 or later
2. (Workaround for Bug 355895) Open the file /org.eclipse.orion.client.core/web/defaults.pref and comment out this line:
"/plugins/jslintPlugin.html":true,
Then reload http://localhost:8080/defaults.pref in your browser to make sure it's not cached.
3. Log into Orion, go to the Plugins page, uninstall jslintPlugin.html
4. Install the new plugin:
http://mamacdon.github.com/0.3/plugins/newoutline/newoutlinePlugin.html
5. The next time you edit a _javascript_ file, you'll see the outline tree in the left-hand pane.
To revert, uninstall newoutlinePlugin.html and uncomment the line from Step 2.
The plugin uses a few heuristics to infer the names of anonymous functions. If you find cases where the names are confusing or wrong, please let me know.
Mark
[1] https://github.com/mishoo/UglifyJS/blob/master/lib/parse-js.js
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev

