(elem any)
| 2116 | } |
| 2117 | |
| 2118 | func (k *kindAndIDAdorner) GetMetadata(elem any) string { |
| 2119 | switch e := elem.(type) { |
| 2120 | case ast.Expr: |
| 2121 | if macroCall, found := k.sourceInfo.GetMacroCall(e.ID()); found { |
| 2122 | return fmt.Sprintf("^#%d:%s#", e.ID(), macroCall.AsCall().FunctionName()) |
| 2123 | } |
| 2124 | var valType string |
| 2125 | switch e.Kind() { |
| 2126 | case ast.CallKind: |
| 2127 | valType = "*expr.Expr_CallExpr" |
| 2128 | case ast.ComprehensionKind: |
| 2129 | valType = "*expr.Expr_ComprehensionExpr" |
| 2130 | case ast.IdentKind: |
| 2131 | valType = "*expr.Expr_IdentExpr" |
| 2132 | case ast.LiteralKind: |
| 2133 | lit := e.AsLiteral() |
| 2134 | switch lit.(type) { |
| 2135 | case types.Bool: |
| 2136 | valType = "*expr.Constant_BoolValue" |
| 2137 | case types.Bytes: |
| 2138 | valType = "*expr.Constant_BytesValue" |
| 2139 | case types.Double: |
| 2140 | valType = "*expr.Constant_DoubleValue" |
| 2141 | case types.Int: |
| 2142 | valType = "*expr.Constant_Int64Value" |
| 2143 | case types.Null: |
| 2144 | valType = "*expr.Constant_NullValue" |
| 2145 | case types.String: |
| 2146 | valType = "*expr.Constant_StringValue" |
| 2147 | case types.Uint: |
| 2148 | valType = "*expr.Constant_Uint64Value" |
| 2149 | default: |
| 2150 | valType = reflect.TypeOf(lit).String() |
| 2151 | } |
| 2152 | case ast.ListKind: |
| 2153 | valType = "*expr.Expr_ListExpr" |
| 2154 | case ast.MapKind, ast.StructKind: |
| 2155 | valType = "*expr.Expr_StructExpr" |
| 2156 | case ast.SelectKind: |
| 2157 | valType = "*expr.Expr_SelectExpr" |
| 2158 | } |
| 2159 | return fmt.Sprintf("^#%d:%s#", e.ID(), valType) |
| 2160 | case ast.EntryExpr: |
| 2161 | return fmt.Sprintf("^#%d:%s#", e.ID(), "*expr.Expr_CreateStruct_Entry") |
| 2162 | } |
| 2163 | return "" |
| 2164 | } |
| 2165 | |
| 2166 | type locationAdorner struct { |
| 2167 | sourceInfo *ast.SourceInfo |
nothing calls this directly
no test coverage detected