Include previous token trailing comments for parameters and type parameters as part of leading comments of them

This commit is contained in:
Sheetal Nandi
2014-08-19 10:00:38 -07:00
parent ecaf4ad221
commit ce89da227d
15 changed files with 62 additions and 94 deletions

View File

@@ -225,7 +225,7 @@ var c1 = (function () {
function c1() {
}
/** sum with property*/
c1.prototype.p2 = function (b) {
c1.prototype.p2 = function (/** number to add*/ b) {
return this.p1 + b;
}; /* trailing comment of method*/
Object.defineProperty(c1.prototype, "p3", {
@@ -235,7 +235,7 @@ var c1 = (function () {
} // trailing comment Getter
,
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
this.p1 = this.p2(value);
} // trailing comment Setter
,
@@ -243,7 +243,7 @@ var c1 = (function () {
configurable: true
});
/** sum with property*/
c1.prototype.pp2 = function (b) {
c1.prototype.pp2 = function (/** number to add*/ b) {
return this.p1 + b;
}; // trailing comment of method
Object.defineProperty(c1.prototype, "pp3", {
@@ -252,14 +252,14 @@ var c1 = (function () {
return this.pp2(this.pp1);
},
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
this.pp1 = this.pp2(value);
},
enumerable: true,
configurable: true
});
/** static sum with property*/
c1.s2 = function (b) {
c1.s2 = function (/** number to add*/ b) {
return c1.s1 + b;
};
Object.defineProperty(c1, "s3", {
@@ -268,7 +268,7 @@ var c1 = (function () {
return c1.s2(c1.s1);
} /*trailing comment 1 getter*/,
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
c1.s1 = c1.s2(value);
} /*trailing comment 2 */ /*setter*/,
enumerable: true,

View File

@@ -280,7 +280,7 @@ function divide(a, b) {
*@param a it is first parameter
*@param c it is third parameter
*/
function jsDocParamTest(a, b, c, d) {
function jsDocParamTest(/** this is inline comment for a */ a, /** this is inline comment for b*/ b, c, d) {
return a + b + c + d;
}
/**/

View File

@@ -38,7 +38,10 @@ function blah3(a: string // trailing commen single line
lambdaFoo = (a, b) => a * b; // This is trailing comment
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
/*leading comment*/(() => 0); //trailing comment
/*leading comment*/(() => 0); //trailing comment
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
}
//// [commentsFunction.js]
/** This comment should appear for foo*/
@@ -46,7 +49,7 @@ function foo() {
} /* trailing comment of function */
foo();
/** This is comment for function signature*/
function fooWithParameters(a,
function fooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -55,12 +58,12 @@ fooWithParameters("a", 10);
/** fooFunc
* comment
*/
var fooFunc = function FooFunctionValue(b) {
var fooFunc = function FooFunctionValue(/** fooFunctionValue param */ b) {
return b;
};
/// lamdaFoo var comment
var lambdaFoo = function (a, b) { return a + b; };
var lambddaNoVarComment = function (a, b) { return a * b; };
var lambdaFoo = function (/**param a*/ a, /**param b*/ b) { return a + b; };
var lambddaNoVarComment = function (/**param a*/ a, /**param b*/ b) { return a * b; };
lambdaFoo(10, 20);
lambddaNoVarComment(10, 20);
function blah(a /* multiline trailing comment
@@ -73,45 +76,9 @@ function blah3(a // trailing commen single line
}
lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment
/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
/** This comment should appear for foo*/
function foo() {
} /* trailing comment of function */
foo();
/** This is comment for function signature*/
function fooWithParameters(/** this is comment about a*/a: string,
/** this is comment for b*/
b: number) {
var d = a;
} // trailing comment of function
fooWithParameters("a", 10);
/** fooFunc
* comment
*/
var fooFunc = function FooFunctionValue(/** fooFunctionValue param */ b: string) {
return b;
}
/// lamdaFoo var comment
var lambdaFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => a + b;
var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b;
lambdaFoo(10, 20);
lambddaNoVarComment(10, 20);
function blah(a: string /* multiline trailing comment
multiline */) {
}
function blah2(a: string /* single line multiple trailing comments */ /* second */) {
}
function blah3(a: string // trailing commen single line
) {
}
lambdaFoo = (a, b) => a * b; // This is trailing comment
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
(function () { return 0; }); //trailing comment
/*leading comment*/ (function () { return 0; }); //trailing comment
function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) {
}
//// [commentsFunction.d.ts]
@@ -130,3 +97,4 @@ declare var lambddaNoVarComment: (a: number, b: number) => number;
declare function blah(a: string): void;
declare function blah2(a: string): void;
declare function blah3(a: string): void;
declare function blah4(a: string, b: string): void;

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 (a) { return "Hello" + a; },
f: function (/**i3_i a*/ a) { return "Hello" + a; },
l: this.f,
/** own x*/
x: this.f(10),

View File

@@ -127,7 +127,7 @@ var m1;
}
m1.fooExport = fooExport;
// shouldn't appear
function foo2Export(a) {
function foo2Export(/**hm*/ a) {
}
m1.foo2Export = foo2Export;
/** foo3Export

View File

@@ -92,7 +92,7 @@ declare var x;
/** Variable comments*/
var myVariable = 10;
/** function comments*/
function foo(p) {
function foo(/** parameter comment*/ p) {
}
/** variable with function type comment*/
var fooVar;

View File

@@ -112,7 +112,7 @@ var c1 = (function () {
return 10;
},
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true
@@ -123,7 +123,7 @@ var c1 = (function () {
return 10;
},
/** private setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true
@@ -134,7 +134,7 @@ var c1 = (function () {
return 10;
},
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true
@@ -195,7 +195,7 @@ var c2 = (function () {
return 10;
},
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true
@@ -206,7 +206,7 @@ var c2 = (function () {
return 10;
},
/** private setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true
@@ -217,7 +217,7 @@ var c2 = (function () {
return 10;
},
/** setter property*/
set: function (value) {
set: function (/** this is value*/ value) {
},
enumerable: true,
configurable: true

View File

@@ -107,7 +107,7 @@ var SimpleConstructor = (function () {
exports.SimpleConstructor = SimpleConstructor;
var ConstructorWithParameters = (function () {
/** This is comment for function signature*/
function ConstructorWithParameters(a,
function ConstructorWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -170,7 +170,7 @@ var GlobalSimpleConstructor = (function () {
})();
var GlobalConstructorWithParameters = (function () {
/** This is comment for function signature*/
function GlobalConstructorWithParameters(a,
function GlobalConstructorWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;

View File

@@ -65,7 +65,7 @@ function foo() {
}
exports.foo = foo;
/** This is comment for function signature*/
function fooWithParameters(a,
function fooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -87,7 +87,7 @@ exports.fooWithOverloads = fooWithOverloads;
function nonExportedFoo() {
}
/** This is comment for function signature*/
function nonExportedFooWithParameters(a,
function nonExportedFooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -107,7 +107,7 @@ function nonExportedFooWithOverloads(a) {
function globalfoo() {
}
/** This is comment for function signature*/
function globalfooWithParameters(a,
function globalfooWithParameters(/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;

View File

@@ -198,7 +198,7 @@ var c1 = (function () {
c1.prototype.foo = function () {
};
/** This is comment for function signature*/
c1.prototype.fooWithParameters = function (a,
c1.prototype.fooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -217,7 +217,7 @@ var c1 = (function () {
c1.prototype.privateFoo = function () {
};
/** This is comment for function signature*/
c1.prototype.privateFooWithParameters = function (a,
c1.prototype.privateFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -236,7 +236,7 @@ var c1 = (function () {
c1.staticFoo = function () {
};
/** This is comment for function signature*/
c1.staticFooWithParameters = function (a,
c1.staticFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -255,7 +255,7 @@ var c1 = (function () {
c1.privateStaticFoo = function () {
};
/** This is comment for function signature*/
c1.privateStaticFooWithParameters = function (a,
c1.privateStaticFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -281,7 +281,7 @@ var c2 = (function () {
c2.prototype.foo = function () {
};
/** This is comment for function signature*/
c2.prototype.fooWithParameters = function (a,
c2.prototype.fooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -300,7 +300,7 @@ var c2 = (function () {
c2.prototype.privateFoo = function () {
};
/** This is comment for function signature*/
c2.prototype.privateFooWithParameters = function (a,
c2.prototype.privateFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -319,7 +319,7 @@ var c2 = (function () {
c2.staticFoo = function () {
};
/** This is comment for function signature*/
c2.staticFooWithParameters = function (a,
c2.staticFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;
@@ -338,7 +338,7 @@ var c2 = (function () {
c2.privateStaticFoo = function () {
};
/** This is comment for function signature*/
c2.privateStaticFooWithParameters = function (a,
c2.privateStaticFooWithParameters = function (/** this is comment about a*/ a,
/** this is comment for b*/
b) {
var d = a;

View File

@@ -40,4 +40,7 @@ function blah3(a: string // trailing commen single line
lambdaFoo = (a, b) => a * b; // This is trailing comment
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
/*leading comment*/(() => 0); //trailing comment
/*leading comment*/(() => 0); //trailing comment
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
}