Start leading comments on new line if the comment starts on different line as node
This commit is contained in:
parent
adc700aba5
commit
29dcc5ba41
5 changed files with 33 additions and 14 deletions
|
@ -1932,6 +1932,11 @@ module ts {
|
||||||
|
|
||||||
function emitLeadingDeclarationComments(node: Declaration) {
|
function emitLeadingDeclarationComments(node: Declaration) {
|
||||||
var leadingComments = getLeadingComments(currentSourceFile.text, node.pos);
|
var leadingComments = getLeadingComments(currentSourceFile.text, node.pos);
|
||||||
|
// If the leading comments start on different line than the start of node, write new line
|
||||||
|
if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos &&
|
||||||
|
currentSourceFile.getLineAndCharacterFromPosition(node.pos).line !== currentSourceFile.getLineAndCharacterFromPosition(leadingComments[0].pos).line) {
|
||||||
|
writer.writeLine();
|
||||||
|
}
|
||||||
emitComments(leadingComments, writer, writeComment);
|
emitComments(leadingComments, writer, writeComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ function foo() {
|
||||||
}
|
}
|
||||||
foo();
|
foo();
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function fooWithParameters(a, /** this is comment for b*/
|
function fooWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,8 @@ var SimpleConstructor = (function () {
|
||||||
exports.SimpleConstructor = SimpleConstructor;
|
exports.SimpleConstructor = SimpleConstructor;
|
||||||
var ConstructorWithParameters = (function () {
|
var ConstructorWithParameters = (function () {
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function ConstructorWithParameters(a, /** this is comment for b*/
|
function ConstructorWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +170,8 @@ var GlobalSimpleConstructor = (function () {
|
||||||
})();
|
})();
|
||||||
var GlobalConstructorWithParameters = (function () {
|
var GlobalConstructorWithParameters = (function () {
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function GlobalConstructorWithParameters(a, /** this is comment for b*/
|
function GlobalConstructorWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ function foo() {
|
||||||
}
|
}
|
||||||
exports.foo = foo;
|
exports.foo = foo;
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function fooWithParameters(a, /** this is comment for b*/
|
function fooWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,8 @@ exports.fooWithOverloads = fooWithOverloads;
|
||||||
function nonExportedFoo() {
|
function nonExportedFoo() {
|
||||||
}
|
}
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function nonExportedFooWithParameters(a, /** this is comment for b*/
|
function nonExportedFooWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,8 @@ function nonExportedFooWithOverloads(a) {
|
||||||
function globalfoo() {
|
function globalfoo() {
|
||||||
}
|
}
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
function globalfooWithParameters(a, /** this is comment for b*/
|
function globalfooWithParameters(a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,8 @@ var c1 = (function () {
|
||||||
c1.prototype.foo = function () {
|
c1.prototype.foo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c1.prototype.fooWithParameters = function (a, /** this is comment for b*/
|
c1.prototype.fooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -216,7 +217,8 @@ var c1 = (function () {
|
||||||
c1.prototype.privateFoo = function () {
|
c1.prototype.privateFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c1.prototype.privateFooWithParameters = function (a, /** this is comment for b*/
|
c1.prototype.privateFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -234,7 +236,8 @@ var c1 = (function () {
|
||||||
c1.staticFoo = function () {
|
c1.staticFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c1.staticFooWithParameters = function (a, /** this is comment for b*/
|
c1.staticFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -252,7 +255,8 @@ var c1 = (function () {
|
||||||
c1.privateStaticFoo = function () {
|
c1.privateStaticFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c1.privateStaticFooWithParameters = function (a, /** this is comment for b*/
|
c1.privateStaticFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -277,7 +281,8 @@ var c2 = (function () {
|
||||||
c2.prototype.foo = function () {
|
c2.prototype.foo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c2.prototype.fooWithParameters = function (a, /** this is comment for b*/
|
c2.prototype.fooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -295,7 +300,8 @@ var c2 = (function () {
|
||||||
c2.prototype.privateFoo = function () {
|
c2.prototype.privateFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c2.prototype.privateFooWithParameters = function (a, /** this is comment for b*/
|
c2.prototype.privateFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -313,7 +319,8 @@ var c2 = (function () {
|
||||||
c2.staticFoo = function () {
|
c2.staticFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c2.staticFooWithParameters = function (a, /** this is comment for b*/
|
c2.staticFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
@ -331,7 +338,8 @@ var c2 = (function () {
|
||||||
c2.privateStaticFoo = function () {
|
c2.privateStaticFoo = function () {
|
||||||
};
|
};
|
||||||
/** This is comment for function signature*/
|
/** This is comment for function signature*/
|
||||||
c2.privateStaticFooWithParameters = function (a, /** this is comment for b*/
|
c2.privateStaticFooWithParameters = function (a,
|
||||||
|
/** this is comment for b*/
|
||||||
b) {
|
b) {
|
||||||
var d = a;
|
var d = a;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue