handleTypeToString converts a Type to its string representation.
(ctx context.Context, params *TypeToTypeNodeParams)
| 2110 | |
| 2111 | // handleTypeToString converts a Type to its string representation. |
| 2112 | func (s *Session) handleTypeToString(ctx context.Context, params *TypeToTypeNodeParams) (any, error) { |
| 2113 | setup, err := s.setupChecker(ctx, params.Snapshot, params.Project) |
| 2114 | if err != nil { |
| 2115 | return nil, err |
| 2116 | } |
| 2117 | defer setup.done() |
| 2118 | |
| 2119 | t, err := setup.resolveTypeHandle(params.Type) |
| 2120 | if err != nil { |
| 2121 | return nil, err |
| 2122 | } |
| 2123 | |
| 2124 | var enclosingDeclaration *ast.Node |
| 2125 | if params.Location != "" { |
| 2126 | enclosingDeclaration, err = setup.sd.resolveNodeHandle(setup.program, params.Location) |
| 2127 | if err != nil { |
| 2128 | return nil, err |
| 2129 | } |
| 2130 | } |
| 2131 | |
| 2132 | if params.Flags != 0 { |
| 2133 | return setup.checker.TypeToStringEx(t, enclosingDeclaration, checker.TypeFormatFlags(params.Flags), nil), nil |
| 2134 | } |
| 2135 | return setup.checker.TypeToStringEx(t, enclosingDeclaration, checker.TypeFormatFlagsAllowUniqueESSymbolType|checker.TypeFormatFlagsUseAliasDefinedOutsideCurrentScope, nil), nil |
| 2136 | } |
| 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) { |
no test coverage detected