@@ -40,6 +40,10 @@ type CollectOption struct {
40
40
CacheResults bool
41
41
}
42
42
43
+ const (
44
+ SUPRESS_COLLECT_ERRORS = true
45
+ )
46
+
43
47
type Collector struct {
44
48
cli * LSPClient
45
49
spec LanguageSpec
@@ -192,7 +196,7 @@ func (c *Collector) Collect(ctx context.Context) error {
192
196
roots = append (roots , sym )
193
197
}
194
198
}
195
- log .Info ("collected symbols." )
199
+ log .Info ("collected %d root symbols. going to collect more syms and dependencies... \n " , len ( roots ) )
196
200
197
201
// collect some extra metadata
198
202
syms := make ([]* DocumentSymbol , 0 , len (roots ))
@@ -203,6 +207,7 @@ func (c *Collector) Collect(ctx context.Context) error {
203
207
}
204
208
c .processSymbol (ctx , sym , 1 )
205
209
}
210
+ log .Info ("collected %d symbols. going to collect dependencies...\n " , len (c .syms ))
206
211
207
212
// collect internal references
208
213
// for _, sym := range syms {
@@ -236,8 +241,11 @@ func (c *Collector) Collect(ctx context.Context) error {
236
241
// }
237
242
// }
238
243
244
+ num_edges := 0
239
245
// collect dependencies
240
- for _ , sym := range syms {
246
+ for i , sym := range syms {
247
+ log .Info ("collecting dependencies %d/%d %s\n " , i , len (syms ), sym .Name )
248
+
241
249
next_token:
242
250
243
251
for i , token := range sym .Tokens {
@@ -283,7 +291,9 @@ func (c *Collector) Collect(ctx context.Context) error {
283
291
// go to definition
284
292
dep , err := c .getSymbolByToken (ctx , token )
285
293
if err != nil || dep == nil {
286
- log .Error ("dep token %v not found: %v\n " , token , err )
294
+ if ! SUPRESS_COLLECT_ERRORS {
295
+ log .Error ("dep token %v not found: %v\n " , token , err )
296
+ }
287
297
continue
288
298
}
289
299
@@ -305,6 +315,7 @@ func (c *Collector) Collect(ctx context.Context) error {
305
315
}
306
316
307
317
log .Debug (" Collect: dep %s -> %s (file: %s -> %s)\n " , sym .Name , dep .Name , sym .Location , token .Location )
318
+ num_edges ++
308
319
c .deps [sym ] = append (c .deps [sym ], dependency {
309
320
Location : token .Location ,
310
321
Symbol : dep ,
@@ -313,6 +324,7 @@ func (c *Collector) Collect(ctx context.Context) error {
313
324
}
314
325
}
315
326
327
+ log .Info ("collected %d symbols, %d edges.\n " , len (c .syms ), num_edges )
316
328
return nil
317
329
}
318
330
@@ -334,7 +346,9 @@ func (c *Collector) getSymbolByTokenWithLimit(ctx context.Context, tok Token, de
334
346
return nil , fmt .Errorf ("definition of token %s not found" , tok )
335
347
}
336
348
if len (defs ) > 1 {
337
- log .Error ("definition of token %s not unique" , tok )
349
+ if ! SUPRESS_COLLECT_ERRORS {
350
+ log .Error ("definition of token %s not unique" , tok )
351
+ }
338
352
}
339
353
return c .getSymbolByLocation (ctx , defs [0 ], depth , tok )
340
354
}
@@ -536,7 +550,9 @@ func (c *Collector) getDepsWithLimit(ctx context.Context, sym *DocumentSymbol, t
536
550
for _ , tp := range tps {
537
551
dep , err := c .getSymbolByTokenWithLimit (ctx , sym .Tokens [tp ], depth )
538
552
if err != nil || sym == nil {
539
- log .Error_skip (1 , "token %v not found its symbol: %v" , tp , err )
553
+ if ! SUPRESS_COLLECT_ERRORS {
554
+ log .Error_skip (1 , "token %v not found its symbol: %v" , tp , err )
555
+ }
540
556
} else {
541
557
d := dependency {sym .Tokens [tp ].Location , dep }
542
558
tsyms [tp ] = d
@@ -629,12 +645,16 @@ func (c *Collector) processSymbol(ctx context.Context, sym *DocumentSymbol, dept
629
645
}
630
646
}
631
647
if i < 0 || i >= len (sym .Tokens ) {
632
- log .Error ("get type token of variable symbol %s failed\n " , sym )
648
+ if ! SUPRESS_COLLECT_ERRORS {
649
+ log .Error ("get type token of variable symbol %s failed\n " , sym )
650
+ }
633
651
return
634
652
}
635
653
tsym , err := c .getSymbolByTokenWithLimit (ctx , sym .Tokens [i ], depth - 1 )
636
654
if err != nil || tsym == nil {
637
- log .Error ("get type symbol for token %s failed:%v\n " , sym .Tokens [i ], err )
655
+ if ! SUPRESS_COLLECT_ERRORS {
656
+ log .Error ("get type symbol for token %s failed:%v\n " , sym .Tokens [i ], err )
657
+ }
638
658
return
639
659
}
640
660
c .vars [sym ] = dependency {
0 commit comments