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

Commit 1a8688a

Browse files
author
Max Schaefer
committed
Extract enough information to distinguish type definitions from alias declarations.
1 parent 4257a68 commit 1a8688a

11 files changed

Lines changed: 1526 additions & 577 deletions

File tree

extractor/dbscheme/tables.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,13 @@ var ImportSpecType = SpecKind.NewBranch("@importspec")
441441
var ValueSpecType = SpecKind.NewBranch("@valuespec")
442442

443443
// TypeSpecType is the type of type declaration specification nodes
444-
var TypeSpecType = SpecKind.NewBranch("@typespec")
444+
var TypeSpecType = NewUnionType("@typespec")
445+
446+
// TypeDefSpecType is the type of type declaration specification nodes corresponding to type definitions
447+
var TypeDefSpecType = SpecKind.NewBranch("@typedefspec", TypeSpecType)
448+
449+
// AliasSpecType is the type of type declaration specification nodes corresponding to alias declarations
450+
var AliasSpecType = SpecKind.NewBranch("@aliasspec", TypeSpecType)
445451

446452
// ObjectType is the type of objects (that is, declared entities)
447453
var ObjectType = NewPrimaryKeyType("@object")

extractor/extractor.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,11 @@ func extractSpec(tw *trap.Writer, spec ast.Spec, parent trap.Label, idx int) {
11491149
if spec == nil {
11501150
return
11511151
}
1152-
kind = dbscheme.TypeSpecType.Index()
1152+
if spec.Assign.IsValid() {
1153+
kind = dbscheme.AliasSpecType.Index()
1154+
} else {
1155+
kind = dbscheme.TypeDefSpecType.Index()
1156+
}
11531157
extractExpr(tw, spec.Name, lbl, 0)
11541158
extractExpr(tw, spec.Type, lbl, 1)
11551159
extractDoc(tw, spec.Doc, lbl)

ql/src/go.dbscheme

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ case @decl.kind of
317317
case @spec.kind of
318318
0 = @importspec
319319
| 1 = @valuespec
320-
| 2 = @typespec;
320+
| 2 = @typedefspec
321+
| 3 = @aliasspec;
322+
323+
@typespec = @typedefspec | @aliasspec;
321324

322325
case @object.kind of
323326
0 = @pkgobject

0 commit comments

Comments
 (0)