@@ -22,7 +22,6 @@ import (
2222 "strings"
2323
2424 "github.com/cloudwego/abcoder/lang/log"
25- "github.com/cloudwego/abcoder/lang/lsp"
2625 . "github.com/cloudwego/abcoder/lang/lsp"
2726 "github.com/cloudwego/abcoder/lang/uniast"
2827)
@@ -44,8 +43,8 @@ func (c *Collector) fileLine(loc Location) uniast.FileLine {
4443 return uniast.FileLine {
4544 File : rel ,
4645 Line : loc .Range .Start .Line + 1 ,
47- StartOffset : lsp . PositionOffset (file_uri , text , loc .Range .Start ),
48- EndOffset : lsp . PositionOffset (file_uri , text , loc .Range .End ),
46+ StartOffset : PositionOffset (file_uri , text , loc .Range .Start ),
47+ EndOffset : PositionOffset (file_uri , text , loc .Range .End ),
4948 }
5049}
5150
@@ -75,7 +74,7 @@ func (c *Collector) Export(ctx context.Context) (*uniast.Repository, error) {
7574 c .filterLocalSymbols ()
7675
7776 // export symbols
78- visited := make (map [* lsp. DocumentSymbol ]* uniast.Identity )
77+ visited := make (map [* DocumentSymbol ]* uniast.Identity )
7978 for _ , symbol := range c .syms {
8079 _ , _ = c .exportSymbol (& repo , symbol , "" , visited )
8180 }
@@ -191,15 +190,15 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
191190 // map receiver to methods
192191 receivers := make (map [* DocumentSymbol ][]* DocumentSymbol , len (c .funcs )/ 4 )
193192 for method , rec := range c .funcs {
194- if method .Kind == lsp . SKMethod && rec .Method != nil && rec .Method .Receiver .Symbol != nil {
193+ if method .Kind == SKMethod && rec .Method != nil && rec .Method .Receiver .Symbol != nil {
195194 receivers [rec .Method .Receiver .Symbol ] = append (receivers [rec .Method .Receiver .Symbol ], method )
196195 }
197196 }
198197
199198 switch k := symbol .Kind ; k {
200199 // Function
201- case lsp . SKFunction , lsp . SKMethod :
202- if p := c .cli .GetParent (symbol ); p != nil && p .Kind == lsp . SKInterface {
200+ case SKFunction , SKMethod :
201+ if p := c .cli .GetParent (symbol ); p != nil && p .Kind == SKInterface {
203202 // NOTICE: no need collect interface method
204203 break
205204 }
@@ -209,6 +208,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
209208 Exported : public ,
210209 }
211210 info := c .funcs [symbol ]
211+ obj .Signature = info .Signature
212212 // NOTICE: type parames collect into types
213213 if info .TypeParams != nil {
214214 for _ , input := range info .TypeParamsSorted {
@@ -262,7 +262,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
262262 id .Name = iid .Name + "<" + id .Name + ">"
263263 }
264264 }
265- if k == lsp . SKFunction {
265+ if k == SKFunction {
266266 // NOTICE: class static method name is: type::method
267267 id .Name += "::" + name
268268 } else {
@@ -285,20 +285,20 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
285285 }
286286 pdep := uniast .NewDependency (* depid , c .fileLine (dep .Location ))
287287 switch dep .Symbol .Kind {
288- case lsp . SKFunction :
288+ case SKFunction :
289289 obj .FunctionCalls = uniast .InsertDependency (obj .FunctionCalls , pdep )
290- case lsp . SKMethod :
290+ case SKMethod :
291291 if obj .MethodCalls == nil {
292292 obj .MethodCalls = make ([]uniast.Dependency , 0 , len (deps ))
293293 }
294294 // NOTICE: use loc token as key here, to make it more readable
295295 obj .MethodCalls = uniast .InsertDependency (obj .MethodCalls , pdep )
296- case lsp . SKVariable , lsp . SKConstant :
296+ case SKVariable , SKConstant :
297297 if obj .GlobalVars == nil {
298298 obj .GlobalVars = make ([]uniast.Dependency , 0 , len (deps ))
299299 }
300300 obj .GlobalVars = uniast .InsertDependency (obj .GlobalVars , pdep )
301- case lsp . SKStruct , lsp . SKTypeParameter , lsp . SKInterface , lsp . SKEnum , lsp . SKClass :
301+ case SKStruct , SKTypeParameter , SKInterface , SKEnum , SKClass :
302302 if obj .Types == nil {
303303 obj .Types = make ([]uniast.Dependency , 0 , len (deps ))
304304 }
@@ -312,7 +312,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
312312 pkg .Functions [id .Name ] = obj
313313
314314 // Type
315- case lsp . SKStruct , lsp . SKTypeParameter , lsp . SKInterface , lsp . SKEnum , lsp . SKClass :
315+ case SKStruct , SKTypeParameter , SKInterface , SKEnum , SKClass :
316316 obj := & uniast.Type {
317317 FileLine : fileLine ,
318318 Content : content ,
@@ -328,7 +328,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
328328 continue
329329 }
330330 switch dep .Symbol .Kind {
331- case lsp . SKStruct , lsp . SKTypeParameter , lsp . SKInterface , lsp . SKEnum , lsp . SKClass :
331+ case SKStruct , SKTypeParameter , SKInterface , SKEnum , SKClass :
332332 obj .SubStruct = uniast .InsertDependency (obj .SubStruct , uniast .NewDependency (* depid , c .fileLine (dep .Location )))
333333 default :
334334 log .Error ("dep symbol %s not collected for \n " , dep .Symbol , id )
@@ -351,12 +351,12 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
351351 obj .Identity = * id
352352 pkg .Types [id .Name ] = obj
353353 // Vars
354- case lsp . SKConstant , lsp . SKVariable :
354+ case SKConstant , SKVariable :
355355 obj := & uniast.Var {
356356 FileLine : fileLine ,
357357 Content : content ,
358358 IsExported : public ,
359- IsConst : k == lsp . SKConstant ,
359+ IsConst : k == SKConstant ,
360360 }
361361 if ty , ok := c .vars [symbol ]; ok {
362362 tok , _ := c .cli .Locate (ty .Location )
@@ -374,18 +374,18 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
374374 return
375375}
376376
377- func mapKind (kind lsp. SymbolKind ) uniast.TypeKind {
377+ func mapKind (kind SymbolKind ) uniast.TypeKind {
378378 switch kind {
379- case lsp . SKStruct :
379+ case SKStruct :
380380 return "struct"
381381 // XXX: C++ should use class instead of struct
382- case lsp . SKClass :
382+ case SKClass :
383383 return "struct"
384- case lsp . SKTypeParameter :
384+ case SKTypeParameter :
385385 return "type-parameter"
386- case lsp . SKInterface :
386+ case SKInterface :
387387 return "interface"
388- case lsp . SKEnum :
388+ case SKEnum :
389389 return "enum"
390390 default :
391391 panic (fmt .Sprintf ("unexpected kind %v" , kind ))
0 commit comments