r44374 - in /branches/upstream/libjavascript-beautifier-perl/current: Changes META.yml Makefile.PL lib/JavaScript/Beautifier.pm t/01-javascript-beauty.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sun Sep 20 04:32:04 UTC 2009
Author: jawnsy-guest
Date: Sun Sep 20 04:31:48 2009
New Revision: 44374
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=44374
Log:
[svn-upgrade] Integrating new upstream version, libjavascript-beautifier-perl (0.15)
Modified:
branches/upstream/libjavascript-beautifier-perl/current/Changes
branches/upstream/libjavascript-beautifier-perl/current/META.yml
branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL
branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm
branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t
Modified: branches/upstream/libjavascript-beautifier-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/Changes?rev=44374&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/Changes (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/Changes Sun Sep 20 04:31:48 2009
@@ -1,4 +1,7 @@
Revision history for JavaScript-Beautifier
+
+0.15 2009.09.17
+ Array tweaks
0.14 2009.08.14
Added an option for the old "function ()" syntax.
Modified: branches/upstream/libjavascript-beautifier-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/META.yml?rev=44374&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/META.yml Sun Sep 20 04:31:48 2009
@@ -1,6 +1,6 @@
---
name: JavaScript-Beautifier
-version: 0.14
+version: 0.15
author:
- 'Fayland Lam <fayland at gmail.com>'
abstract: Beautify Javascript (beautifier for javascript)
@@ -12,11 +12,13 @@
Getopt::Long: 0
Pod::Usage: 0
Test::More: 0
+configure_requires:
+ Module::Build: 0.35
provides:
JavaScript::Beautifier:
file: lib/JavaScript/Beautifier.pm
- version: 0.14
-generated_by: Module::Build version 0.33
+ version: 0.15
+generated_by: Module::Build version 0.35
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL?rev=44374&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/Makefile.PL Sun Sep 20 04:31:48 2009
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.33
+# Note: this file was auto-generated by Module::Build::Compat version 0.35
use ExtUtils::MakeMaker;
WriteMakefile
(
Modified: branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm?rev=44374&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/lib/JavaScript/Beautifier.pm Sun Sep 20 04:31:48 2009
@@ -3,7 +3,7 @@
use warnings;
use strict;
-our $VERSION = '0.14';
+our $VERSION = '0.15';
our $AUTHORITY = 'cpan:FAYLAND';
use base 'Exporter';
@@ -11,7 +11,7 @@
@EXPORT_OK = qw/js_beautify/;
my ( @input, @output, @modes );
-my ( $token_text, $last_type, $last_text, $last_word, $current_mode, $indent_string, $parser_pos, $in_case, $prefix, $token_type, $do_block_just_closed,$var_line, $var_line_tainted, $if_line_flag );
+my ( $token_text, $last_type, $last_text, $last_last_text, $last_word, $current_mode, $previous_mode, $indent_string, $parser_pos, $in_case, $prefix, $token_type, $do_block_just_closed, $var_line, $var_line_tainted, $if_line_flag );
my @whitespace = split('', "\n\r\t ");
my @wordchar = split('', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$');
@@ -42,6 +42,7 @@
$last_word = ''; # last 'TK_WORD' passed
$last_type = 'TK_START_EXPR'; # last token type
$last_text = ''; # last token text
+ $last_last_text = ''; # pre-last token text
@output = ();
$do_block_just_closed = 0;
@@ -59,7 +60,6 @@
my $t = get_next_token($parser_pos);
$token_text = $t->[0];
$token_type = $t->[1];
- #print STDERR "text $token_text type $token_type last $last_text $last_type " . join('', @output) . "\n";
if ( $token_type eq 'TK_EOF' ) {
last;
}
@@ -68,14 +68,23 @@
$var_line = 0;
if ( $token_text eq '[' ) {
- if ( $current_mode eq '[EXPRESSION]') {
- # multidimensional arrays
- # (more like two-dimensional, though: deeper levels are treated the same as the second)
- print_newline();
- push @output, $indent_string;
- }
- }
- if ( $token_text eq '[' ) {
+ if ( $last_type eq 'TK_WORD' ) {
+ # this is array index specifier, break immediately
+ set_mode('(EXPRESSION)');
+ print_token();
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
+ }
+ if ( $current_mode eq '[EXPRESSION]' ) {
+ if ( $last_last_text eq ']' && $last_text eq ',' ) {
+ # ], [ goes to new line
+ indent();
+ print_newline();
+ } elsif ($last_text eq '[') {
+ indent();
+ print_newline();
+ }
+ }
+
set_mode('[EXPRESSION]');
} else {
set_mode('(EXPRESSION)');
@@ -96,11 +105,15 @@
print_space();
}
print_token();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_END_EXPR' ) {
+ $previous_mode = $current_mode;
restore_mode();
- print_token();
- $last_type = $token_type;$last_text = $token_text;next;
+ if ( $token_text eq ']' && $current_mode eq '[EXPRESSION]' && ($previous_mode ne '(EXPRESSION)') ) {
+ unindent();
+ }
+ print_token();
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_START_BLOCK' ) {
if ( $last_word eq 'do' ) {
set_mode('DO_BLOCK');
@@ -116,7 +129,7 @@
}
print_token();
indent();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_END_BLOCK' ) {
if ( $last_type eq 'TK_START_BLOCK' ) {
# nothing
@@ -128,14 +141,14 @@
}
print_token();
restore_mode();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_WORD' ) {
if ( $do_block_just_closed ) {
print_space();
print_token();
print_space();
$do_block_just_closed = 0;
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
}
if ( $token_text eq 'case' || $token_text eq 'default' ) {
if ( $last_text eq ':' ) {
@@ -149,7 +162,7 @@
}
print_token();
$in_case = 1;
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
}
$prefix = 'NONE';
if ( $last_type eq 'TK_END_BLOCK' ) {
@@ -213,11 +226,11 @@
if ( $token_text eq 'if' || $token_text eq 'else' ) {
$if_line_flag = 1;
}
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_SEMICOLON' ) {
print_token();
$var_line = 0;
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_STRING' ) {
if ( $last_type eq 'TK_START_BLOCK' || $last_type eq 'TK_END_BLOCK' || $last_type eq 'TK_SEMICOLON' ) {
print_newline();
@@ -225,7 +238,7 @@
print_space();
}
print_token();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_type eq 'TK_OPERATOR' ) {
my $start_delim = 1;
my $end_delim = 1;
@@ -243,12 +256,12 @@
print_token(); # colon really asks for separate treatment
print_newline();
$in_case = 0;
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
}
if ( $token_text eq '::' ) {
# no spaces around exotic namespacing syntax operator
print_token();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
}
if ( $token_text eq ',' ) {
@@ -274,7 +287,7 @@
print_space();
}
}
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ( $token_text eq '--' || $token_text eq '++' ) { # unary operators special case
if ( $last_text eq ';' ) {
if ( $current_mode eq 'BLOCK') {
@@ -326,21 +339,21 @@
if ( $end_delim ) {
print_space();
}
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ($token_type eq 'TK_BLOCK_COMMENT') {
print_newline();
print_token();
print_newline();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ($token_type eq 'TK_COMMENT') {
# print_newline();
print_space();
print_token();
print_newline();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
} elsif ($token_type eq 'TK_UNKNOWN') {
print_token();
- $last_type = $token_type;$last_text = $token_text;next;
+ $last_last_text = $last_text;$last_type = $token_type;$last_text = $token_text;next;
}
$last_type = $token_type;
$last_text = $token_text;
Modified: branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t?rev=44374&op=diff
==============================================================================
--- branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t (original)
+++ branches/upstream/libjavascript-beautifier-perl/current/t/01-javascript-beauty.t Sun Sep 20 04:31:48 2009
@@ -116,9 +116,15 @@
# allow unescaped / in char classes
[ 'a(/[a/b]/);b()', "a(/[a/b]/);\nb()" ],
[ 'a=[[1,2],[4,5],[7,8]]', "a = [\n [1, 2],\n [4, 5],\n [7, 8]]" ],
- );
+ [ 'a=[a[1],b[4],c[d[7]]]', "a = [a[1], b[4], c[d[7]]]" ],
+ [ '[1,2,[3,4,[5,6],7],8]', "[1, 2, [3, 4, [5, 6], 7], 8]" ],
+
+ [ '[[["1","2"],["3","4"]],[["5","6","7"],["8","9","0"]],[["1","2","3"],["4","5","6","7"],["8","9","0"]]]',
+ qq~[\n [\n ["1", "2"],\n ["3", "4"]],\n [\n ["5", "6", "7"],\n ["8", "9", "0"]],\n [\n ["1", "2", "3"],\n ["4", "5", "6", "7"],\n ["8", "9", "0"]]]~ ],
+
+);
-plan tests => scalar @tests + 12;
+plan tests => scalar @tests + 13;
foreach my $t (@tests) {
my $run_js = js_beautify($t->[0], $opts );
@@ -141,6 +147,7 @@
["var a2, b2, c2, d2 = 0, c = function() {}, d = '';", "var a2, b2, c2, d2 = 0,\nc = function() {},\nd = '';"],
['var o2=$.extend(a,function(){alert(x);}', "var o2 = \$.extend(a, function() {\n alert(x);\n}"],
['var o2=$.extend(a);function(){alert(x);}', "var o2 = \$.extend(a);\nfunction() {\n alert(x);\n}"],
+ ['{[y[a]];keep_indent;}', "{\n [y[a]];\n keep_indent;\n}"],
);
foreach my $t (@test_space_after_anon_function_false) {
my $run_js = js_beautify($t->[0], { %$opts, space_after_anon_function => 0 } );
More information about the Pkg-perl-cvs-commits
mailing list