Add tests for preserving comments

This commit is contained in:
Yui T 2015-08-06 17:28:11 -07:00
parent 01667eff1c
commit 8f18912d28
8 changed files with 12 additions and 11 deletions

View file

@ -112,7 +112,7 @@ exports.delint = delint;
var fileNames = process.argv.slice(2);
fileNames.forEach(function (fileName) {
// Parse a file
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, true);
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, /*setParentNodes */ true);
// delint it
delint(sourceFile);
});

View file

@ -8,4 +8,5 @@ s.map(// do something
//// [commentInMethodCall.js]
//commment here
var s;
s.map(function () { });
s.map(// do something
function () { });

View file

@ -6,5 +6,5 @@ var v = {
//// [commentsBeforeFunctionExpression1.js]
var v = {
f: function (a) { return 0; }
f: /**own f*/ function (a) { return 0; }
};

View file

@ -89,7 +89,7 @@ var i2_i_nc_fnfoo = i2_i.nc_fnfoo;
var i2_i_nc_fnfoo_r = i2_i.nc_fnfoo(10);
var i3_i;
i3_i = {
f: function (/**i3_i a*/ a) { return "Hello" + a; },
f: /**own f*/ function (/**i3_i a*/ a) { return "Hello" + a; },
l: this.f,
/** own x*/
x: this.f(10),

View file

@ -20,8 +20,8 @@ function makePoint(x) {
};
}
;
var point = makePoint(2);
var x = point.x;
var /*4*/ point = makePoint(2);
var /*2*/ x = point.x;
point.x = 30;

View file

@ -16,8 +16,8 @@ function makePoint(x) {
};
}
;
var point = makePoint(2);
var x = point.x;
var /*4*/ point = makePoint(2);
var /*2*/ x = point.x;
//// [declFileObjectLiteralWithOnlyGetter.d.ts]

View file

@ -17,7 +17,7 @@ function makePoint(x) {
};
}
;
var point = makePoint(2);
var /*3*/ point = makePoint(2);
point.x = 30;

View file

@ -890,7 +890,7 @@ var Formatting;
return result;
};
Indenter.GetIndentSizeFromIndentText = function (indentText, editorOptions) {
return GetIndentSizeFromText(indentText, editorOptions, false);
return GetIndentSizeFromText(indentText, editorOptions, /*includeNonIndentChars:*/ false);
};
Indenter.GetIndentSizeFromText = function (text, editorOptions, includeNonIndentChars) {
var indentSize = 0;
@ -1174,7 +1174,7 @@ var Formatting;
return null;
var origIndentText = this.snapshot.GetText(new Span(indentEditInfo.OrigIndentPosition, indentEditInfo.OrigIndentLength()));
var newIndentText = indentEditInfo.Indentation();
var origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, true);
var origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, /*includeNonIndentChars*/ true);
var newIndentSize = Indenter.GetIndentSizeFromIndentText(newIndentText, this.editorOptions);
// Check the child's position whether it's before the parent position
// if so indent the child based on the first token on the line as opposed to the parent position