Scope analysis - coloring variables by scope (UNCLASSIFIED)

59 views
Skip to first unread message

Cheney, Edward A SFC MIL USA FORSCOM

unread,
Mar 9, 2013, 9:40:28 AM3/9/13
to js-t...@googlegroups.com
Classification: UNCLASSIFIED
Some months ago I wrote a beautifier that I named JSPretty. I am just completed an enhancement that will color variables respective of their scope where they are declared. This operation offers the convenience benefit of instantly identifying qualities like closure and inheritance depth.

The application with a code sample can be found at:
http://prettydiff.com/jspretty.xhtml?c=white&jsscope&s=http://prettydiff.com/lib/markupmin.js

The application up for demo at:
http://prettydiff.com/jspretty.xhtml?c=white&jsscope

The code can be accessed at these locations:
http://prettydiff.com/lib/jspretty.js
https://github.com/austincheney/Pretty-Diff/blob/master/lib/jspretty.js

Currently the application supplies unique colors up to a depth of 16, but does not support global variables at this time. In case anybody is wondering, yes, the original idea for coloring scope comes from Crockford about a month ago with an enhancement to JSLint. Feedback and criticism are appreciated.

Thanks,
Austin
Classification: UNCLASSIFIED

Michal Kuklis

unread,
Mar 9, 2013, 9:45:52 AM3/9/13
to js-t...@googlegroups.com
This is pretty cool Austin.

I think this is a similar idea to what Douglas Crockford has mentioned
in his recent talk about monads. I've been looking for something similar
to this for a while. I'm going to check it out :)

Michal

Michal Kuklis

unread,
Mar 9, 2013, 10:10:45 AM3/9/13
to js-t...@googlegroups.com
Ah sorry I haven't read your full email before responding... I just got
really excited about it :)

Daniel Lamb

unread,
Apr 5, 2013, 8:37:52 PM4/5/13
to js-t...@googlegroups.com
NIce work, I just had the same idea myself after watching that video. Here's my take on it
ScreenShot.png

Cheney, Edward A SFC MIL USA FORSCOM

unread,
Apr 6, 2013, 9:59:45 AM4/6/13
to js-t...@googlegroups.com
Classification: UNCLASSIFIED
Daniel,

I found some bugs in your application. Comments appear to be a corrupting factor as well some character sequences such as "}());". I am confident these will be easily resolved with a bit more testing.

I think the presentation of your approach spells out the colors more than my own attempt. I have not decided why I have formed that opinion. I dunno, maybe you chose better colors than I did or maybe its that the coloring is directly applied to editable code.

Good job!

Austin

On 04/06/13, Daniel Lamb <dani...@gmail.com> wrote:

> NIce work, I just had the same idea myself after watching that video. Here's my take on it
> https://github.com/daniellmb/java_script-Scope-Context-Coloring
>
>
> On Saturday, March 9, 2013 6:40:28 AM UTC-8, austincheney wrote:
> > Classification: UNCLASSIFIED
> >
> > Some months ago I wrote a beautifier that I named JSPretty.  I am just completed an enhancement that will color variables respective of their scope where they are declared.  This operation offers the convenience benefit of instantly identifying qualities like closure and inheritance depth.
> >
> >
> >
> > The application with a code sample can be found at:
> >
> > http://prettydiff.com/jspretty.xhtml?c=white&jsscope&s=http://prettydiff.com/lib/markupmin.js
> >
> >
> >
> > The application up for demo at:
> >
> > http://prettydiff.com/jspretty.xhtml?c=white&jsscope
> >
> >
> >
> > The code can be accessed at these locations:
> >
> > http://prettydiff.com/lib/jspretty.js
> >
> > https://github.com/austincheney/Pretty-Diff/blob/master/lib/jspretty.js
> >
> >
> >
> > Currently the application supplies unique colors up to a depth of 16, but does not support global variables at this time.  In case anybody is wondering, yes, the original idea for coloring scope comes from Crockford about a month ago with an enhancement to JSLint.  Feedback and criticism are appreciated.
> >
> >
> >
> > Thanks,
> >
> > Austin
> >
> > Classification: UNCLASSIFIED
> >
> >
>
>
>
>
>
>
> --
>
> --
>
> http://clausreinke.github.com/js-tools/resources.html(blockedhttp://clausreinke.github.com/js-tools/resources.html) - tool information
>
> http://groups.google.com/group/js-tools(blockedhttp://groups.google.com/group/js-tools) - mailing list information
>
>  
>
> ---
>
> You received this message because you are subscribed to the Google Groups "js-tools" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to js-tools+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out(blockedhttps://groups.google.com/groups/opt_out).
>
>  
>
>  
>
>
Classification: UNCLASSIFIED
Reply all
Reply to author
Forward
0 new messages