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

Method ScanJSDocCommentTextToken

internal/scanner/scanner.go:1374–1405  ·  view source on GitHub ↗

** In addition to the usual JSDoc ast.Kinds, can also return ast.KindJSDocCommentTextToken */

(inBackticks bool)

Source from the content-addressed store, hash-verified

1372
1373/** In addition to the usual JSDoc ast.Kinds, can also return ast.KindJSDocCommentTextToken */
1374func (s *Scanner) ScanJSDocCommentTextToken(inBackticks bool) ast.Kind {
1375 s.fullStartPos = s.pos
1376 s.tokenFlags = ast.TokenFlagsNone
1377 if s.pos >= len(s.text) {
1378 s.token = ast.KindEndOfFile
1379 return s.token
1380 }
1381 s.tokenStart = s.pos
1382 for ch, size := s.charAndSize(); s.pos < len(s.text) && !stringutil.IsLineBreak(ch) && ch != '`'; ch, size = s.charAndSize() {
1383 if !inBackticks {
1384 if ch == '{' {
1385 break
1386 } else if ch == '@' && s.pos >= 0 {
1387 // @ doesn't start a new tag inside ``, and elsewhere, only after whitespace and before identifier
1388 previous, _ := utf8.DecodeLastRuneInString(s.text[:s.pos])
1389 if stringutil.IsWhiteSpaceSingleLine(previous) {
1390 next, _ := utf8.DecodeRuneInString(s.text[s.pos+size:])
1391 if IsIdentifierStart(next) {
1392 break
1393 }
1394 }
1395 }
1396 }
1397 s.pos += size
1398 }
1399 if s.pos == s.tokenStart {
1400 return s.ScanJSDocToken()
1401 }
1402 s.tokenValue = s.text[s.tokenStart:s.pos]
1403 s.token = ast.KindJSDocCommentTextToken
1404 return s.token
1405}
1406
1407// Peek at the character at the current scanner position (expected to be right after '@')
1408// and return true if a JSDoc tag can follow. Identifier starts indicate a tag name.

Callers 1

Calls 6

charAndSizeMethod · 0.95
ScanJSDocTokenMethod · 0.95
IsLineBreakFunction · 0.92
IsWhiteSpaceSingleLineFunction · 0.92
lenFunction · 0.85
IsIdentifierStartFunction · 0.85

Tested by

no test coverage detected