(node *ast.LiteralLikeNode, sourceFile *ast.SourceFile, flags getLiteralTextFlags)
| 191 | } |
| 192 | |
| 193 | func (p *Printer) getLiteralTextOfNode(node *ast.LiteralLikeNode, sourceFile *ast.SourceFile, flags getLiteralTextFlags) string { |
| 194 | if ast.IsStringLiteral(node) { |
| 195 | if textSourceNode, ok := p.emitContext.textSource[node]; ok && textSourceNode != nil { |
| 196 | var text string |
| 197 | switch textSourceNode.Kind { |
| 198 | default: |
| 199 | return p.getLiteralTextOfNode(textSourceNode, ast.GetSourceFileOfNode(textSourceNode), flags) |
| 200 | case ast.KindNumericLiteral: |
| 201 | text = textSourceNode.Text() |
| 202 | case ast.KindIdentifier, ast.KindPrivateIdentifier, ast.KindJsxNamespacedName: |
| 203 | text = p.getTextOfNode(textSourceNode, false) |
| 204 | } |
| 205 | |
| 206 | switch { |
| 207 | case flags&getLiteralTextFlagsJsxAttributeEscape != 0: |
| 208 | return "\"" + escapeJsxAttributeString(text, QuoteCharDoubleQuote) + "\"" |
| 209 | case flags&getLiteralTextFlagsNeverAsciiEscape != 0 || p.emitContext.EmitFlags(node)&EFNoAsciiEscaping != 0: |
| 210 | return "\"" + EscapeString(text, QuoteCharDoubleQuote) + "\"" |
| 211 | default: |
| 212 | return "\"" + escapeNonAsciiString(text, QuoteCharDoubleQuote) + "\"" |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | // !!! Printer option to control whether to terminate unterminated literals |
| 217 | if p.emitContext.EmitFlags(node)&EFNoAsciiEscaping != 0 { |
| 218 | flags |= getLiteralTextFlagsNeverAsciiEscape |
| 219 | } |
| 220 | if p.Options.Target >= core.ScriptTargetES2021 { |
| 221 | flags |= getLiteralTextFlagsAllowNumericSeparator |
| 222 | } |
| 223 | return getLiteralText(node, core.Coalesce(sourceFile, p.currentSourceFile), flags) |
| 224 | } |
| 225 | |
| 226 | // `node` must be one of Identifier | PrivateIdentifier | LiteralExpression | JsxNamespacedName |
| 227 | func (p *Printer) getTextOfNode(node *ast.Node, includeTrivia bool) string { |
no test coverage detected