Reviewers: MikeSamuel,
Description:
Currently, the js prettyprint renderer indents something like this:
{
___.loadModule({
'instantiate': function (___, IMPORTS___) {
var $v = ___.readImport(IMPORTS___, '$v', {
'getOuters': {
'()': { }
}
});
}
});
}
The deep indentation is awkward in several ways, especially when
it gets close to the 80-column limit and the prettyprinter ends
up emitting 2-3 tokens per line in a skinny far-right column.
This change makes the prettyprinter indent like this:
{
___.loadModule({
'instantiate': function (___, IMPORTS___) {
var $v = ___.readImport(IMPORTS___, '$v', {
'getOuters': {
'()': { }
}
});
}
});
}
1. Each open bracket adds 2 to indent.
2. Continued statements add 2 to indent.
This is an example of the difference, output from 'wc':
lines words chars
4376 16944 120763 jquery-1.3.2.js
15788 22446 1283779 jquery-1.3.2.out.js (old)
6336 20607 389524 jquery-1.3.2.out.js (new)
Using the minifier will be smaller, of course.
This change is about improving the debugging experience.
Please review this at http://codereview.appspot.com/110079
Affected files:
M src/com/google/caja/render/Indent.java
M src/com/google/caja/render/Indenter.java
M tests/com/google/caja/demos/applet/caja-applet-cajita-golden.js
M tests/com/google/caja/demos/applet/caja-applet-valija-golden.js
M tests/com/google/caja/opensocial/example-rewritten.xml
M tests/com/google/caja/parser/js/rendergolden2.txt
M tests/com/google/caja/parser/quasiliteral/testModule.co.js
M tests/com/google/caja/plugin/HtmlEmitterTest.java
M tests/com/google/caja/render/JsPrettyPrinterTest.java
M tests/com/google/caja/render/sbs-golden.js
M tests/com/google/caja/render/ssp-golden.txt
M tests/com/google/caja/service/CajolingServiceTest.java