MCPcopy Create free account
hub / github.com/microsoft/typescript-go / Text

Method Text

internal/ast/ast.go:272–308  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270}
271
272func (n *Node) Text() string {
273 switch n.Kind {
274 case KindIdentifier:
275 return n.AsIdentifier().Text
276 case KindPrivateIdentifier:
277 return n.AsPrivateIdentifier().Text
278 case KindStringLiteral:
279 return n.AsStringLiteral().Text
280 case KindNumericLiteral:
281 return n.AsNumericLiteral().Text
282 case KindBigIntLiteral:
283 return n.AsBigIntLiteral().Text
284 case KindMetaProperty:
285 return n.AsMetaProperty().Name().Text()
286 case KindNoSubstitutionTemplateLiteral:
287 return n.AsNoSubstitutionTemplateLiteral().Text
288 case KindTemplateHead:
289 return n.AsTemplateHead().Text
290 case KindTemplateMiddle:
291 return n.AsTemplateMiddle().Text
292 case KindTemplateTail:
293 return n.AsTemplateTail().Text
294 case KindJsxNamespacedName:
295 return n.AsJsxNamespacedName().Namespace.Text() + ":" + n.AsJsxNamespacedName().name.Text()
296 case KindRegularExpressionLiteral:
297 return n.AsRegularExpressionLiteral().Text
298 case KindJSDocText:
299 return strings.Join(n.AsJSDocText().text, "")
300 case KindJSDocLink:
301 return strings.Join(n.AsJSDocLink().text, "")
302 case KindJSDocLinkCode:
303 return strings.Join(n.AsJSDocLinkCode().text, "")
304 case KindJSDocLinkPlain:
305 return strings.Join(n.AsJSDocLinkPlain().text, "")
306 }
307 panic(fmt.Sprintf("Unhandled case in Node.Text: %T", n.data))
308}
309
310func (n *Node) Expression() *Node {
311 switch n.Kind {

Calls 15

AsIdentifierMethod · 0.95
AsPrivateIdentifierMethod · 0.95
AsStringLiteralMethod · 0.95
AsNumericLiteralMethod · 0.95
AsBigIntLiteralMethod · 0.95
AsMetaPropertyMethod · 0.95
AsTemplateHeadMethod · 0.95
AsTemplateMiddleMethod · 0.95
AsTemplateTailMethod · 0.95
AsJsxNamespacedNameMethod · 0.95

Tested by

no test coverage detected