MCPcopy
hub / github.com/microsoft/typescript-go / emitExpression

Method emitExpression

internal/printer/printer.go:3213–3335  ·  view source on GitHub ↗
(node *ast.Expression, precedence ast.OperatorPrecedence)

Source from the content-addressed store, hash-verified

3211}
3212
3213func (p *Printer) emitExpression(node *ast.Expression, precedence ast.OperatorPrecedence) {
3214 parens := ast.GetExpressionPrecedence(ast.SkipPartiallyEmittedExpressions(node)) < precedence
3215 if parens {
3216 p.writePunctuation("(")
3217 }
3218
3219 switch node.Kind {
3220 // Keywords
3221 case ast.KindTrueKeyword, ast.KindFalseKeyword, ast.KindNullKeyword:
3222 p.emitTokenNode(node)
3223 case ast.KindThisKeyword, ast.KindSuperKeyword, ast.KindImportKeyword:
3224 p.emitKeywordExpression(node.AsKeywordExpression())
3225
3226 // Literals
3227 case ast.KindNumericLiteral:
3228 p.emitNumericLiteral(node.AsNumericLiteral())
3229 case ast.KindBigIntLiteral:
3230 p.emitBigIntLiteral(node.AsBigIntLiteral())
3231 case ast.KindStringLiteral:
3232 p.emitStringLiteral(node.AsStringLiteral())
3233 case ast.KindRegularExpressionLiteral:
3234 p.emitRegularExpressionLiteral(node.AsRegularExpressionLiteral())
3235 case ast.KindNoSubstitutionTemplateLiteral:
3236 p.emitNoSubstitutionTemplateLiteral(node.AsNoSubstitutionTemplateLiteral())
3237
3238 // Identifiers
3239 case ast.KindIdentifier:
3240 p.emitIdentifierReference(node.AsIdentifier())
3241 case ast.KindPrivateIdentifier:
3242 p.emitPrivateIdentifier(node.AsPrivateIdentifier())
3243
3244 // Expressions
3245 case ast.KindArrayLiteralExpression:
3246 p.emitArrayLiteralExpression(node.AsArrayLiteralExpression())
3247 case ast.KindObjectLiteralExpression:
3248 p.emitObjectLiteralExpression(node.AsObjectLiteralExpression())
3249 case ast.KindPropertyAccessExpression:
3250 p.emitPropertyAccessExpression(node.AsPropertyAccessExpression())
3251 case ast.KindElementAccessExpression:
3252 p.emitElementAccessExpression(node.AsElementAccessExpression())
3253 case ast.KindCallExpression:
3254 p.emitCallExpression(node.AsCallExpression())
3255 case ast.KindNewExpression:
3256 p.emitNewExpression(node.AsNewExpression())
3257 case ast.KindTaggedTemplateExpression:
3258 p.emitTaggedTemplateExpression(node.AsTaggedTemplateExpression())
3259 case ast.KindTypeAssertionExpression:
3260 p.emitTypeAssertionExpression(node.AsTypeAssertion())
3261 case ast.KindParenthesizedExpression:
3262 p.emitParenthesizedExpression(node.AsParenthesizedExpression())
3263 case ast.KindFunctionExpression:
3264 p.emitFunctionExpression(node.AsFunctionExpression())
3265 case ast.KindArrowFunction:
3266 p.emitArrowFunction(node.AsArrowFunction())
3267 case ast.KindDeleteExpression:
3268 p.emitDeleteExpression(node.AsDeleteExpression())
3269 case ast.KindTypeOfExpression:
3270 p.emitTypeOfExpression(node.AsTypeOfExpression())

Callers 15

emitEntityNameMethod · 0.95
emitDecoratorMethod · 0.95
emitInitializerMethod · 0.95
emitLiteralTypeMethod · 0.95
emitArgumentMethod · 0.95
emitCalleeMethod · 0.95
emitNewExpressionMethod · 0.95

Calls 15

writePunctuationMethod · 0.95
emitTokenNodeMethod · 0.95
emitKeywordExpressionMethod · 0.95
emitNumericLiteralMethod · 0.95
emitBigIntLiteralMethod · 0.95
emitStringLiteralMethod · 0.95
emitPrivateIdentifierMethod · 0.95

Tested by

no test coverage detected