Skip to content

Commit 83847e7

Browse files
committed
fix: get json.Types and build graph
1 parent 5ba1764 commit 83847e7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lang/collect/export.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
286286
obj.GlobalVars = make([]uniast.Dependency, 0, len(deps))
287287
}
288288
obj.GlobalVars = uniast.InsertDependency(obj.GlobalVars, pdep)
289-
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum:
289+
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum, lsp.SKClass:
290290
if obj.Types == nil {
291291
obj.Types = make([]uniast.Dependency, 0, len(deps))
292292
}
@@ -300,7 +300,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
300300
pkg.Functions[id.Name] = obj
301301

302302
// Type
303-
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum:
303+
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum, lsp.SKClass:
304304
obj := &uniast.Type{
305305
FileLine: fileLine,
306306
Content: content,
@@ -317,7 +317,7 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
317317
continue
318318
}
319319
switch dep.Symbol.Kind {
320-
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum:
320+
case lsp.SKStruct, lsp.SKTypeParameter, lsp.SKInterface, lsp.SKEnum, lsp.SKClass:
321321
obj.SubStruct = append(obj.SubStruct, uniast.NewDependency(*depid, c.fileLine(dep.Location)))
322322
default:
323323
log.Error("dep symbol %s not collected for \n", dep.Symbol, id)
@@ -370,6 +370,9 @@ func mapKind(kind lsp.SymbolKind) uniast.TypeKind {
370370
switch kind {
371371
case lsp.SKStruct:
372372
return "struct"
373+
// XXX: C++ should use class instead of struct
374+
case lsp.SKClass:
375+
return "struct"
373376
case lsp.SKTypeParameter:
374377
return "type-parameter"
375378
case lsp.SKInterface:

lang/cxx/spec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func (c *CxxSpec) NameSpace(path string) (string, string, error) {
5959
}
6060

6161
func (c *CxxSpec) ShouldSkip(path string) bool {
62-
if !strings.HasSuffix(path, ".c") {
63-
return true
62+
if strings.HasSuffix(path, ".c") || strings.HasSuffix(path, ".h") {
63+
return false
6464
}
65-
return false
65+
return true
6666
}
6767

6868
func (c *CxxSpec) IsDocToken(tok lsp.Token) bool {

0 commit comments

Comments
 (0)