Kindsys: Replace "Declaration" with "Definition" (#62515)
* s/Declaration/Definition/g * s/DeclForGen/DefForGen/g * Rename some local vars
This commit is contained in:
@@ -39,20 +39,20 @@ func (gen *genTSVeneerIndex) JennyName() string {
|
||||
return "TSVeneerIndexJenny"
|
||||
}
|
||||
|
||||
func (gen *genTSVeneerIndex) Generate(decls ...*DeclForGen) (*codejen.File, error) {
|
||||
func (gen *genTSVeneerIndex) Generate(decls ...*DefForGen) (*codejen.File, error) {
|
||||
tsf := new(ast.File)
|
||||
for _, decl := range decls {
|
||||
sch := decl.Lineage().Latest()
|
||||
for _, def := range decls {
|
||||
sch := def.Lineage().Latest()
|
||||
f, err := typescript.GenerateTypes(sch, &typescript.TypeConfig{
|
||||
RootName: decl.Properties.Common().Name,
|
||||
Group: decl.Properties.Common().LineageIsGroup,
|
||||
RootName: def.Properties.Common().Name,
|
||||
Group: def.Properties.Common().LineageIsGroup,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", decl.Properties.Common().Name, err)
|
||||
return nil, fmt.Errorf("%s: %w", def.Properties.Common().Name, err)
|
||||
}
|
||||
elems, err := gen.extractTSIndexVeneerElements(decl, f)
|
||||
elems, err := gen.extractTSIndexVeneerElements(def, f)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", decl.Properties.Common().Name, err)
|
||||
return nil, fmt.Errorf("%s: %w", def.Properties.Common().Name, err)
|
||||
}
|
||||
tsf.Nodes = append(tsf.Nodes, elems...)
|
||||
}
|
||||
@@ -60,9 +60,9 @@ func (gen *genTSVeneerIndex) Generate(decls ...*DeclForGen) (*codejen.File, erro
|
||||
return codejen.NewFile(filepath.Join(gen.dir, "index.gen.ts"), []byte(tsf.String()), gen), nil
|
||||
}
|
||||
|
||||
func (gen *genTSVeneerIndex) extractTSIndexVeneerElements(decl *DeclForGen, tf *ast.File) ([]ast.Decl, error) {
|
||||
lin := decl.Lineage()
|
||||
comm := decl.Properties.Common()
|
||||
func (gen *genTSVeneerIndex) extractTSIndexVeneerElements(def *DefForGen, tf *ast.File) ([]ast.Decl, error) {
|
||||
lin := def.Lineage()
|
||||
comm := def.Properties.Common()
|
||||
|
||||
// Check the root, then walk the tree
|
||||
rootv := lin.Latest().Underlying()
|
||||
@@ -90,7 +90,7 @@ func (gen *genTSVeneerIndex) extractTSIndexVeneerElements(decl *DeclForGen, tf *
|
||||
name = sels[0].String()
|
||||
}
|
||||
|
||||
// Search the generated TS AST for the type and default decl nodes
|
||||
// Search the generated TS AST for the type and default def nodes
|
||||
pair := findDeclNode(name, tf)
|
||||
if pair.T == nil {
|
||||
// No generated type for this item, skip it
|
||||
@@ -139,7 +139,7 @@ func (gen *genTSVeneerIndex) extractTSIndexVeneerElements(decl *DeclForGen, tf *
|
||||
}
|
||||
|
||||
vpath := fmt.Sprintf("v%v", thema.LatestVersion(lin)[0])
|
||||
if decl.Properties.Common().Maturity.Less(kindsys.MaturityStable) {
|
||||
if def.Properties.Common().Maturity.Less(kindsys.MaturityStable) {
|
||||
vpath = "x"
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ func (gen *genTSVeneerIndex) extractTSIndexVeneerElements(decl *DeclForGen, tf *
|
||||
})
|
||||
}
|
||||
|
||||
// TODO emit a decl in the index.gen.ts that ensures any custom veneer types are "compatible" with current version raw types
|
||||
// TODO emit a def in the index.gen.ts that ensures any custom veneer types are "compatible" with current version raw types
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@@ -205,13 +205,13 @@ type tsVeneerAttr struct {
|
||||
|
||||
func findDeclNode(name string, tf *ast.File) declPair {
|
||||
var p declPair
|
||||
for _, decl := range tf.Nodes {
|
||||
for _, def := range tf.Nodes {
|
||||
// Peer through export keywords
|
||||
if ex, is := decl.(ast.ExportKeyword); is {
|
||||
decl = ex.Decl
|
||||
if ex, is := def.(ast.ExportKeyword); is {
|
||||
def = ex.Decl
|
||||
}
|
||||
|
||||
switch x := decl.(type) {
|
||||
switch x := def.(type) {
|
||||
case ast.TypeDecl:
|
||||
if x.Name.Name == name {
|
||||
p.T = &x.Name
|
||||
|
||||
Reference in New Issue
Block a user