handlePrintNode decodes a binary-encoded AST node and prints it to text.
(_ context.Context, params *PrintNodeParams)
| 2137 | |
| 2138 | // handlePrintNode decodes a binary-encoded AST node and prints it to text. |
| 2139 | func (s *Session) handlePrintNode(_ context.Context, params *PrintNodeParams) (string, error) { |
| 2140 | data, err := base64.StdEncoding.DecodeString(params.Data) |
| 2141 | if err != nil { |
| 2142 | return "", fmt.Errorf("%w: invalid base64 data: %w", ErrClientError, err) |
| 2143 | } |
| 2144 | |
| 2145 | node, err := encoder.DecodeNodes(data) |
| 2146 | if err != nil { |
| 2147 | return "", fmt.Errorf("%w: failed to decode AST: %w", ErrClientError, err) |
| 2148 | } |
| 2149 | |
| 2150 | p := printer.NewPrinter(printer.PrinterOptions{ |
| 2151 | PreserveSourceNewlines: params.PreserveSourceNewlines, |
| 2152 | NeverAsciiEscape: params.NeverAsciiEscape, |
| 2153 | TerminateUnterminatedLiterals: params.TerminateUnterminatedLiterals, |
| 2154 | }, printer.PrintHandlers{}, nil) |
| 2155 | return p.Emit(node, nil), nil |
| 2156 | } |
| 2157 | |
| 2158 | // handleGetIntrinsicType returns an intrinsic type (any, string, number, etc.). |
| 2159 | func (s *Session) handleGetIntrinsicType(ctx context.Context, params *GetIntrinsicTypeParams, getter func(*checker.Checker) *checker.Type) (*TypeResponse, error) { |
no test coverage detected