fix(33233): add outlining for comments before property access expression

This commit is contained in:
Alexander T 2020-05-18 15:22:03 +03:00
parent 7fc456f2d7
commit 2b703d254a
3 changed files with 36 additions and 0 deletions

View file

@ -42,6 +42,10 @@ namespace ts.OutliningElementsCollector {
addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out);
}
if (isFunctionLike(n) && isBinaryExpression(n.parent) && isPropertyAccessExpression(n.parent.left)) {
addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out);
}
const span = getOutliningSpanForNode(n, sourceFile);
if (span) out.push(span);

View file

@ -110,6 +110,26 @@
//// const sum2 = (y, z) =>[| {
//// return y + z;
//// }|];
////
////function Foo()[| {
//// [|/**
//// * Description
//// *
//// * @param {string} param
//// * @returns
//// */|]
//// this.method = function (param)[| {
//// }|]
////
//// [|/**
//// * Description
//// *
//// * @param {string} param
//// * @returns
//// */|]
//// function method(param)[| {
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges());

View file

@ -72,6 +72,18 @@
////// One single line comment should not be collapsed
////class WithOneSingleLineComment[| {
////}|]
////
////function Foo()[| {
//// [|// comment 1
//// // comment 2|]
//// this.method = function (param)[| {
//// }|]
////
//// [|// comment 1
//// // comment 2|]
//// function method(param)[| {
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges());