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