Skip to content

Commit 82b0547

Browse files
dragomirtitianDanielRosenwasser
authored andcommitted
Fixed outlining spans for chained method calls. (#35860)
1 parent 4942fd2 commit 82b0547

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ namespace ts.OutliningElementsCollector {
4545
if (span) out.push(span);
4646

4747
depthRemaining--;
48-
if (isIfStatement(n) && n.elseStatement && isIfStatement(n.elseStatement)) {
48+
if (isCallExpression(n)) {
49+
depthRemaining++;
50+
visitNonImportNode(n.expression);
51+
depthRemaining--;
52+
n.arguments.forEach(visitNonImportNode);
53+
n.typeArguments?.forEach(visitNonImportNode);
54+
}
55+
else if (isIfStatement(n) && n.elseStatement && isIfStatement(n.elseStatement)) {
4956
// Consider an 'else if' to be on the same depth as the 'if'.
5057
visitNonImportNode(n.expression);
5158
visitNonImportNode(n.thenStatement);
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
// Tests that each 'else if' does not count towards a higher nesting depth.
4+
5+
////declare var router: any;
6+
////router
7+
//// .get("/", async(ctx) =>[|{
8+
//// ctx.body = "base";
9+
//// }|])
10+
//// .post("/a", async(ctx) =>[|{
11+
//// //a
12+
//// }|])
13+
//// .get("/", async(ctx) =>[|{
14+
//// ctx.body = "base";
15+
//// }|])
16+
//// .post("/a", async(ctx) =>[|{
17+
//// //a
18+
//// }|])
19+
//// .get("/", async(ctx) =>[|{
20+
//// ctx.body = "base";
21+
//// }|])
22+
//// .post("/a", async(ctx) =>[|{
23+
//// //a
24+
//// }|])
25+
//// .get("/", async(ctx) =>[|{
26+
//// ctx.body = "base";
27+
//// }|])
28+
//// .post("/a", async(ctx) =>[|{
29+
//// //a
30+
//// }|])
31+
//// .get("/", async(ctx) =>[|{
32+
//// ctx.body = "base";
33+
//// }|])
34+
//// .post("/a", async(ctx) =>[|{
35+
//// //a
36+
//// }|])
37+
//// .get("/", async(ctx) =>[|{
38+
//// ctx.body = "base";
39+
//// }|])
40+
//// .post("/a", async(ctx) =>[|{
41+
//// //a
42+
//// }|])
43+
//// .get("/", async(ctx) =>[|{
44+
//// ctx.body = "base";
45+
//// }|])
46+
//// .post("/a", async(ctx) =>[|{
47+
//// //a
48+
//// }|])
49+
//// .get("/", async(ctx) =>[|{
50+
//// ctx.body = "base";
51+
//// }|])
52+
//// .post("/a", async(ctx) =>[|{
53+
//// //a
54+
//// }|])
55+
//// .get("/", async(ctx) =>[|{
56+
//// ctx.body = "base";
57+
//// }|])
58+
//// .post("/a", async(ctx) =>[|{
59+
//// //a
60+
//// }|])
61+
//// .get("/", async(ctx) =>[|{
62+
//// ctx.body = "base";
63+
//// }|])
64+
//// .post("/a", async(ctx) =>[|{
65+
//// //a
66+
//// }|])
67+
//// .get("/", async(ctx) =>[|{
68+
//// ctx.body = "base";
69+
//// }|])
70+
//// .post("/a", async(ctx) =>[|{
71+
//// //a
72+
//// }|])
73+
//// .get("/", async(ctx) =>[|{
74+
//// ctx.body = "base";
75+
//// }|])
76+
//// .post("/a", async(ctx) =>[|{
77+
//// //a
78+
//// }|])
79+
//// .get("/", async(ctx) =>[|{
80+
//// ctx.body = "base";
81+
//// }|])
82+
//// .post("/a", async(ctx) =>[|{
83+
//// //a
84+
//// }|])
85+
//// .get("/", async(ctx) =>[|{
86+
//// ctx.body = "base";
87+
//// }|])
88+
//// .post("/a", async(ctx) =>[|{
89+
//// //a
90+
//// }|])
91+
//// .get("/", async(ctx) =>[|{
92+
//// ctx.body = "base";
93+
//// }|])
94+
//// .post("/a", async(ctx) =>[|{
95+
//// //a
96+
//// }|])
97+
//// .get("/", async(ctx) =>[|{
98+
//// ctx.body = "base";
99+
//// }|])
100+
//// .post("/a", async(ctx) =>[|{
101+
//// //a
102+
//// }|])
103+
//// .get("/", async(ctx) =>[|{
104+
//// ctx.body = "base";
105+
//// }|])
106+
//// .post("/a", async(ctx) =>[|{
107+
//// //a
108+
//// }|])
109+
//// .get("/", async(ctx) =>[|{
110+
//// ctx.body = "base";
111+
//// }|])
112+
//// .post("/a", async(ctx) =>[|{
113+
//// //a
114+
//// }|])
115+
116+
verify.outliningSpansInCurrentFile(test.ranges());

0 commit comments

Comments
 (0)