Consolidate shared UI, hardware transport, and translation tooling
This commit is contained in:
1 parent
ed6951f4cd
commit
2c612de63b
61 files changed
+2417
-1573
No files matched your search
@@ -35,13 +35,13 @@ func Collect(root string) ([]string, error) {
|
||||
ast.Inspect(file, func(node ast.Node) bool {
|
||||
switch n := node.(type) {
|
||||
case *ast.CallExpr:
|
||||
if len(n.Args) > 0 && is_message_call(n.Fun) {
|
||||
if len(n.Args) > 0 && isMessageCall(n.Fun) {
|
||||
add(found, n.Args[0])
|
||||
}
|
||||
case *ast.CompositeLit:
|
||||
typeName, ok := elided[n]
|
||||
if n.Type != nil {
|
||||
typeName = type_name(n.Type)
|
||||
typeName = exprTypeName(n.Type)
|
||||
} else if !ok {
|
||||
return true
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func Collect(root string) ([]string, error) {
|
||||
element = pair.Value
|
||||
}
|
||||
if inner, ok := element.(*ast.CompositeLit); ok && inner.Type == nil {
|
||||
elided[inner] = element_type_name(n.Type, typeName)
|
||||
elided[inner] = elementTypeName(n.Type, typeName)
|
||||
}
|
||||
}
|
||||
if !uiTypes[typeName] {
|
||||
@@ -88,32 +88,32 @@ func Collect(root string) ([]string, error) {
|
||||
// uiTypes are the presentation values whose Label and Title are message IDs.
|
||||
var uiTypes = map[string]bool{"Form": true, "Tab": true, "Control": true, "Choice": true, "Option": true}
|
||||
|
||||
func type_name(expr ast.Expr) string {
|
||||
func exprTypeName(expr ast.Expr) string {
|
||||
switch t := expr.(type) {
|
||||
case *ast.Ident:
|
||||
return t.Name
|
||||
case *ast.SelectorExpr:
|
||||
return t.Sel.Name
|
||||
case *ast.StarExpr:
|
||||
return type_name(t.X)
|
||||
return exprTypeName(t.X)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// element_type_name names the type of elided values inside a composite literal.
|
||||
func element_type_name(outer ast.Expr, inherited string) string {
|
||||
// elementTypeName names the type of elided values inside a composite literal.
|
||||
func elementTypeName(outer ast.Expr, inherited string) string {
|
||||
switch t := outer.(type) {
|
||||
case *ast.ArrayType:
|
||||
return type_name(t.Elt)
|
||||
return exprTypeName(t.Elt)
|
||||
case *ast.MapType:
|
||||
return type_name(t.Value)
|
||||
return exprTypeName(t.Value)
|
||||
case nil:
|
||||
return inherited
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func is_message_call(fun ast.Expr) bool {
|
||||
func isMessageCall(fun ast.Expr) bool {
|
||||
switch f := fun.(type) {
|
||||
case *ast.Ident:
|
||||
return f.Name == "Mark"
|
||||
|
||||
Reference in new issue
Block a user