-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
113 additions
and
253 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/NUglify.Tests/TestData/JS/Expected/Assignments/MultiVars.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
var a="a",b="b",c,d="d",e,f,g;d&&(e="e");f="f",g="g" | ||
var a="a",b="b",c,d="d",e,f,g;d&&(e="e");f="f";g="g" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
let x = 1; // a comment | ||
let x = 1 | ||
// a comment | ||
// another comment | ||
let y = 2; | ||
let y = 2 |
4 changes: 1 addition & 3 deletions
4
src/NUglify.Tests/TestData/JS/Expected/Comments/EndWithImportantComment.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 2 additions & 14 deletions
16
src/NUglify.Tests/TestData/JS/Expected/Comments/ImportantComment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
/*! | ||
* this is an example of an "important" comment | ||
* that we want to keep | ||
*/ | ||
function foo(){ | ||
/*! this too */ | ||
}var a=12; | ||
/*! | ||
* this is another one, but it's between a couple var statements | ||
*/ | ||
var b=13; | ||
/** @preserve This is an important comment because of the @preserve token */ | ||
/** | ||
*/function foo(){/*! this too */}var a=12/*! * this is another one, but it's between a couple var statements */;var b=13/** @preserve This is an important comment because of the @preserve token *//** | ||
** @license And so is this, because of the @license token | ||
*/ | ||
for(var ndx=0;ndx<10;++ndx) | ||
/*! inside a block */ | ||
; | ||
*/;for(var ndx=0;ndx<10;++ndx)/*! inside a block */; |
10 changes: 3 additions & 7 deletions
10
src/NUglify.Tests/TestData/JS/Expected/Comments/ImportantIgnore.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
var p,i;if(location.hash)throw"hash exists";else alert("no hash");for(p in window)alert(p+" = "+window[p]);for(;;)if(window.timer)break;do{ | ||
//! keep one | ||
if(+new Date-1e6){ | ||
//! keep two | ||
break} | ||
/*! keep three */ | ||
}while(1);foo:for(i=0;i<100;++i)if(i%3)break foo | ||
var p,i;if(location.hash)throw"hash exists";else alert("no hash");for(p in window)alert(p+" = "+window[p]);for(;;)if(window.timer)break;do{//! keep one | ||
if(+new Date-1e6){//! keep two | ||
break}/*! keep three */}while(1);foo:for(i=0;i<100;++i)if(i%3)break foo |
2 changes: 1 addition & 1 deletion
2
src/NUglify.Tests/TestData/JS/Expected/Comments/OnlyImportantComment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/*! Copyright 2010 by Contoso Corp. All rights reserved */ | ||
/*! Copyright 2010 by Contoso Corp. All rights reserved */ |
4 changes: 1 addition & 3 deletions
4
src/NUglify.Tests/TestData/JS/Expected/Comments/TwoImportantComments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
/*! First Important Comment */ | ||
/*! Second Important Comment */ | ||
var a=10 | ||
/*! First Important Comment *//*! Second Important Comment */var a=10 |
3 changes: 1 addition & 2 deletions
3
src/NUglify.Tests/TestData/JS/Expected/Modules/ExportCombine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//! start my implicit module | ||
function n(n,t){return n+t}export function mul(n,t){return n*t}function t(n){return mul(n,n)}function i(n,t){if(t==0)return 1;for(var i=1;--t;)i=mul(i,n);return i}export const pi=3.1415927,negOne=-1;export var accumulator=0,foo="bar";export{n as sum,t as square,i as pow}; | ||
//! end my implicit module | ||
function n(n,t){return n+t}export function mul(n,t){return n*t}function t(n){return mul(n,n)}function i(n,t){if(t==0)return 1;for(var i=1;--t;)i=mul(i,n);return i}export const pi=3.1415927,negOne=-1;export var accumulator=0,foo="bar";export{n as sum,t as square,i as pow}//! end my implicit module |
4 changes: 1 addition & 3 deletions
4
src/NUglify.Tests/TestData/JS/Expected/Syntax/EmptyStatement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
function foo(){for(var ndx=0;ndx<10;++ndx);}if(ndx) | ||
/*! important */ | ||
; | ||
function foo(){for(var ndx=0;ndx<10;++ndx);}if(ndx)/*! important */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
function uxp_toggleElementVisibility_return(e) | ||
{ | ||
var o = e.style; | ||
return 'none' === o.display | ||
? (o.display = '', 1) | ||
: (o.display = 'none', 0); | ||
} | ||
|
||
// we need to keep those parens around the comma operator | ||
// so that we continue to have two arguments, the second of | ||
// which is a comma-operator expression. | ||
var t = foo(bar, (ack,gag)); | ||
|
||
// the comma-operators in this var statement should be wrapped in parens to | ||
// distinguish them from the var comma separators | ||
var y = (t, foo, bar); | ||
|
||
// multiple commas, for op-prec sake | ||
// because they are evaluated left-to-right, there should be no parens in this list | ||
z = a, b, c, document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using NUglify.JavaScript.Visitors; | ||
|
||
namespace NUglify.JavaScript.Syntax | ||
{ | ||
public class Comment : AstNode | ||
{ | ||
// Indicates if this was a multiline comment (by syntax only, doesn't necessarily contain a \n) | ||
public bool IsMultiLine { get; set; } | ||
public bool IsImportant { get; set; } | ||
public string Value { get; set; } | ||
|
||
// this is for determining if a node in a block AFTER a return/break/continue should be removed. We don't want to remove an important comment, so SAY it's a declaration. | ||
public override bool IsDeclaration => true; | ||
|
||
public Comment(SourceContext context, bool isImportant, bool isMultiLine) : base(context) | ||
{ | ||
IsImportant = isImportant; | ||
IsMultiLine = isMultiLine; | ||
Value = Context.Code; | ||
} | ||
|
||
public override void Accept(IVisitor visitor) | ||
{ | ||
visitor?.Visit(this); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.