Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit cf3d607

Browse files
atwalg2jasonLaster
authored andcommitted
[Preview] should ignore some labels (#5531)
1 parent 5d5914d commit cf3d607

File tree

2 files changed

+8
-90
lines changed

2 files changed

+8
-90
lines changed

src/workers/parser/getSymbols.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ function extractSymbol(path: SimplePath, symbols) {
219219
if (t.isIdentifier(path)) {
220220
let { start, end } = path.node.loc;
221221

222+
if (t.isClassMethod(path.parent)) {
223+
return;
224+
}
225+
226+
if (t.isProperty(path.parent)) {
227+
return;
228+
}
229+
222230
if (path.node.typeAnnotation) {
223231
const column = path.node.typeAnnotation.loc.start.column;
224232
end = { ...end, column };

src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,16 @@ identifiers:
6060
[(8, 26), (8, 27)] b b
6161
[(10, 6), (18, 1)] Obj Obj
6262
[(10, 6), (10, 9)] Obj Obj
63-
[(11, 2), (11, 5)] foo foo
6463
[(12, 2), (12, 9)] doThing doThing
6564
[(13, 4), (13, 11)] console console
6665
[(13, 12), (13, 15)] log log
67-
[(15, 2), (15, 14)] doOtherThing doOtherThing
6866
[(20, 0), (20, 3)] Obj Obj
6967
[(20, 4), (20, 12)] property property
7068
[(21, 0), (21, 3)] Obj Obj
7169
[(21, 4), (21, 17)] otherProperty otherProperty
7270
[(23, 6), (23, 11)] Ultra Ultra
73-
[(24, 2), (24, 13)] constructor constructor
7471
[(25, 4), (25, 8)] [(25, 4), (25, 8)] this this
7572
[(25, 9), (25, 16)] awesome awesome
76-
[(28, 2), (28, 11)] beAwesome beAwesome
77-
[(28, 12), (28, 18)] person person
7873
[(29, 4), (29, 11)] console console
7974
[(29, 12), (29, 15)] log log
8075
[(29, 19), (29, 25)] person person
@@ -162,15 +157,11 @@ comments:
162157
163158
identifiers:
164159
[(1, 6), (1, 10)] Test Test
165-
[(2, 2), (2, 13)] constructor constructor
166160
[(3, 4), (3, 8)] [(3, 4), (3, 8)] this this
167161
[(3, 9), (3, 12)] foo foo
168-
[(6, 2), (6, 5)] bar bar
169-
[(6, 6), (6, 7)] a a
170162
[(7, 4), (7, 11)] console console
171163
[(7, 12), (7, 15)] log log
172164
[(7, 23), (7, 24)] a a
173-
[(10, 2), (10, 5)] baz baz
174165
[(10, 8), (10, 9)] b b
175166
[(11, 11), (11, 12)] b b
176167
[(15, 6), (15, 11)] Test2 Test2
@@ -263,48 +254,34 @@ comments:
263254
264255
identifiers:
265256
[(5, 6), (5, 11)] Punny Punny
266-
[(6, 2), (6, 13)] constructor constructor
267-
[(6, 14), (6, 19)] props props
268257
[(8, 4), (8, 8)] [(8, 4), (8, 8)] this this
269258
[(8, 9), (8, 16)] onClick onClick
270259
[(8, 19), (8, 23)] [(8, 19), (8, 23)] this this
271260
[(8, 24), (8, 31)] onClick onClick
272261
[(8, 32), (8, 36)] bind bind
273262
[(8, 37), (8, 41)] [(8, 37), (8, 41)] this this
274-
[(11, 2), (11, 19)] componentDidMount componentDidMount
275-
[(13, 2), (13, 9)] onClick onClick
276-
[(15, 2), (15, 10)] renderMe renderMe
277263
[(16, 25), (16, 29)] [(16, 25), (16, 29)] this this
278264
[(16, 30), (16, 37)] onClick onClick
279-
[(19, 2), (19, 8)] render render
280265
[(5, 20), (5, 29)] Component Component
281266
[(26, 6), (32, 2)] TodoView TodoView
282267
[(26, 6), (26, 14)] TodoView TodoView
283268
[(26, 17), (26, 25)] Backbone Backbone
284269
[(26, 26), (26, 30)] View View
285270
[(26, 31), (26, 37)] extend extend
286-
[(27, 2), (27, 9)] tagName tagName
287-
[(29, 2), (29, 8)] render render
288271
[(30, 4), (30, 11)] console console
289272
[(30, 12), (30, 15)] log log
290273
[(34, 6), (40, 2)] TodoClass TodoClass
291274
[(34, 6), (34, 15)] TodoClass TodoClass
292275
[(34, 18), (34, 29)] createClass createClass
293-
[(35, 2), (35, 9)] tagName tagName
294-
[(37, 2), (37, 8)] render render
295276
[(38, 4), (38, 11)] console console
296277
[(38, 12), (38, 15)] log log
297278
[(42, 0), (42, 9)] TodoClass TodoClass
298279
[(42, 12), (42, 23)] createClass createClass
299-
[(43, 2), (43, 9)] tagName tagName
300-
[(45, 2), (45, 8)] render render
301280
[(46, 4), (46, 11)] console console
302281
[(46, 12), (46, 15)] log log
303282
[(50, 0), (50, 3)] app app
304283
[(50, 4), (50, 13)] TodoClass TodoClass
305284
[(50, 16), (50, 27)] createClass createClass
306-
[(51, 2), (51, 9)] tagName tagName
307-
[(53, 2), (53, 8)] render render
308285
[(54, 4), (54, 11)] console console
309286
[(54, 12), (54, 15)] log log
310287
[(62, 9), (62, 15)] Button Button
@@ -400,17 +377,9 @@ comments:
400377
401378
identifiers:
402379
[(1, 6), (1, 35)]
403-
[(1, 8), (1, 9)] b b
404-
[(1, 8), (1, 9)] b b
405-
[(1, 11), (1, 16)] resty resty
406-
[(1, 11), (1, 16)] resty resty
407380
[(1, 21), (1, 28)] compute compute
408381
[(1, 29), (1, 34)] stuff stuff
409382
[(2, 6), (2, 33)]
410-
[(2, 8), (2, 13)] first first
411-
[(2, 15), (2, 16)] f f
412-
[(2, 18), (2, 22)] last last
413-
[(2, 24), (2, 25)] l l
414383
[(2, 30), (2, 33)] obj obj
415384
[(4, 7), (4, 8)] a a
416385
[(4, 13), (4, 17)] rest rest
@@ -426,20 +395,11 @@ identifiers:
426395
[(8, 14), (8, 19)] index index
427396
[(8, 21), (8, 28)] element element
428397
[(11, 6), (11, 42)]
429-
[(11, 8), (11, 9)] a a
430398
[(11, 11), (11, 13)] aa aa
431-
[(11, 20), (11, 21)] b b
432399
[(11, 23), (11, 25)] bb bb
433-
[(11, 36), (11, 37)] a a
434400
[(12, 6), (12, 38)]
435-
[(12, 8), (12, 12)] temp temp
436-
[(12, 17), (12, 20)] foo foo
437-
[(12, 22), (12, 27)] foooo foooo
438401
[(12, 35), (12, 38)] obj obj
439402
[(14, 4), (14, 33)]
440-
[(14, 7), (14, 10)] key key
441-
[(14, 13), (14, 16)] foo foo
442-
[(14, 23), (14, 24)] z z
443403
[(16, 7), (16, 15)] prefName prefName
444404
[(16, 19), (16, 33)] prefsBlueprint prefsBlueprint
445405
[(16, 34), (16, 46)] accessorName accessorName
@@ -475,8 +435,6 @@ comments:
475435
identifiers:
476436
[(1, 0), (1, 8)] dispatch dispatch
477437
[(1, 14), (1, 20)] action action
478-
[(1, 23), (1, 30)] PROMISE PROMISE
479-
[(1, 33), (1, 40)] promise promise
480438
481439
classes:
482440
@@ -597,67 +555,36 @@ comments:
597555
identifiers:
598556
[(1, 6), (1, 27)] obj obj
599557
[(1, 6), (1, 9)] obj obj
600-
[(1, 14), (1, 15)] a a
601-
[(1, 19), (1, 20)] b b
602558
[(2, 6), (2, 33)] foo foo
603559
[(2, 6), (2, 9)] foo foo
604560
[(2, 12), (2, 16)] obj2 obj2
605561
[(2, 17), (2, 18)] c c
606562
[(2, 19), (2, 33)] secondProperty secondProperty
607563
[(5, 6), (5, 49)] com com
608564
[(5, 6), (5, 9)] com com
609-
[(5, 15), (5, 16)] a a
610-
[(5, 21), (5, 22)] b b
611-
[(5, 30), (5, 31)] d d
612-
[(5, 42), (5, 43)] b b
613565
[(7, 0), (7, 3)] app app
614566
[(7, 4), (7, 12)] TodoView TodoView
615567
[(7, 15), (7, 23)] Backbone Backbone
616568
[(7, 24), (7, 30)] extend extend
617-
[(8, 2), (8, 8)] render render
618569
[(12, 0), (12, 3)] obj obj
619570
[(12, 4), (12, 7)] foo foo
620-
[(12, 12), (12, 13)] a a
621-
[(12, 17), (12, 18)] b b
622-
[(12, 27), (12, 28)] b b
623571
[(13, 0), (13, 3)] com com
624-
[(13, 8), (13, 9)] a a
625-
[(13, 13), (13, 14)] b b
626-
[(13, 23), (13, 24)] b b
627572
[(16, 6), (16, 32)] res res
628573
[(16, 6), (16, 9)] res res
629-
[(16, 15), (16, 16)] a a
630-
[(16, 25), (16, 26)] b b
631574
[(17, 6), (17, 30)] res2 res2
632575
[(17, 6), (17, 10)] res2 res2
633-
[(17, 15), (17, 16)] a a
634-
[(17, 21), (17, 22)] b b
635576
[(18, 6), (18, 45)] res3 res3
636577
[(18, 6), (18, 10)] res3 res3
637-
[(18, 15), (18, 16)] a a
638-
[(18, 21), (18, 22)] b b
639-
[(18, 30), (18, 31)] b b
640-
[(18, 36), (18, 37)] c c
641578
[(19, 6), (19, 45)] res4 res4
642579
[(19, 6), (19, 10)] res4 res4
643-
[(19, 17), (19, 18)] a a
644-
[(19, 29), (19, 30)] b b
645580
[(19, 32), (19, 33)] a a
646581
[(19, 34), (19, 35)] b b
647582
[(19, 36), (19, 37)] c c
648583
[(19, 38), (19, 39)] v v
649584
[(19, 40), (19, 41)] d d
650585
[(21, 9), (21, 15)] params params
651-
[(21, 18), (21, 19)] a a
652-
[(21, 18), (21, 19)] a a
653-
[(21, 21), (21, 22)] b b
654-
[(21, 21), (21, 22)] b b
655586
[(22, 4), (22, 32)] pars pars
656587
[(22, 4), (22, 8)] pars pars
657-
[(22, 22), (22, 23)] a a
658-
[(22, 22), (22, 23)] a a
659-
[(22, 25), (22, 26)] b b
660-
[(22, 25), (22, 26)] b b
661588
[(23, 6), (23, 43)] evil evil
662589
[(23, 6), (23, 10)] evil evil
663590
[(23, 13), (23, 17)] obj2 obj2
@@ -714,8 +641,6 @@ comments:
714641
identifiers:
715642
[(4, 6), (7, 3)] globalObject globalObject
716643
[(4, 6), (4, 18)] globalObject globalObject
717-
[(5, 3), (5, 8)] first first
718-
[(6, 3), (6, 7)] last last
719644
[(8, 11), (8, 19)] sayHello sayHello
720645
[(8, 21), (8, 25)] name name
721646
[(9, 20), (9, 24)] name name
@@ -774,8 +699,6 @@ comments:
774699
775700
identifiers:
776701
[(1, 6), (1, 9)] App App
777-
[(2, 2), (2, 13)] renderHello renderHello
778-
[(2, 14), (2, 18)] name name
779702
[(3, 20), (3, 24)] name name
780703
[(1, 18), (1, 27)] Component Component
781704
@@ -826,7 +749,6 @@ identifiers:
826749
[(17, 0), (17, 5)] child child
827750
[(23, 6), (31, 1)] obj obj
828751
[(23, 6), (23, 9)] obj obj
829-
[(24, 2), (24, 5)] foo foo
830752
[(24, 16), (24, 20)] name name
831753
[(28, 2), (28, 5)] bar bar
832754
@@ -927,7 +849,6 @@ comments:
927849
[(1, 0), (1, 20)]
928850
929851
identifiers:
930-
[(4, 2), (4, 5)] foo foo
931852
[(8, 2), (8, 5)] foo foo
932853
[(13, 0), (13, 3)] foo foo
933854
[(14, 0), (14, 3)] obj obj
@@ -937,26 +858,18 @@ identifiers:
937858
[(17, 5), (17, 8)] foo foo
938859
[(18, 4), (18, 29)]
939860
[(18, 5), (18, 8)] foo foo
940-
[(18, 5), (18, 8)] foo foo
941861
[(20, 1), (20, 4)] foo foo
942862
[(21, 2), (21, 5)] foo foo
943-
[(21, 2), (21, 5)] foo foo
944-
[(22, 2), (22, 5)] bar bar
945863
[(22, 7), (22, 10)] foo foo
946864
[(24, 9), (24, 11)] fn fn
947865
[(24, 13), (24, 16)] foo foo
948866
[(25, 9), (25, 11)] fn fn
949867
[(25, 13), (25, 16)] foo foo
950-
[(25, 13), (25, 16)] foo foo
951868
[(26, 9), (26, 11)] fn fn
952-
[(26, 13), (26, 16)] bar bar
953869
[(26, 18), (26, 21)] foo foo
954870
[(28, 6), (28, 9)] Cls Cls
955-
[(29, 2), (29, 5)] foo foo
956-
[(33, 2), (33, 5)] foo foo
957871
[(42, 6), (42, 25)] defaultObj defaultObj
958872
[(42, 6), (42, 16)] defaultObj defaultObj
959-
[(42, 20), (42, 21)] a a
960873
[(43, 6), (43, 29)] defaultArr defaultArr
961874
[(43, 6), (43, 16)] defaultArr defaultArr
962875
[(44, 9), (44, 10)] a a
@@ -1121,14 +1034,11 @@ identifiers:
11211034
[(5, 17), (5, 25)] Backbone Backbone
11221035
[(5, 26), (5, 30)] View View
11231036
[(5, 31), (5, 37)] extend extend
1124-
[(6, 2), (6, 9)] tagName tagName
1125-
[(7, 2), (7, 12)] initialize initialize
11261037
[(8, 2), (8, 9)] doThing doThing
11271038
[(8, 10), (8, 11)] b b
11281039
[(9, 4), (9, 11)] console console
11291040
[(9, 12), (9, 15)] log log
11301041
[(9, 22), (9, 23)] b b
1131-
[(11, 2), (11, 8)] render render
11321042
[(12, 11), (12, 15)] [(12, 11), (12, 15)] this this
11331043
11341044
classes:

0 commit comments

Comments
 (0)