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

Method emitSourceMapsBeforeToken

internal/printer/printer.go:5915–5935  ·  view source on GitHub ↗
(token ast.Kind, pos int, contextNode *ast.Node, flags tokenEmitFlags)

Source from the content-addressed store, hash-verified

5913}
5914
5915func (p *Printer) emitSourceMapsBeforeToken(token ast.Kind, pos int, contextNode *ast.Node, flags tokenEmitFlags) *sourceMapState {
5916 if !p.shouldEmitTokenSourceMaps(token, pos, contextNode, flags) {
5917 return nil
5918 }
5919
5920 emitFlags := p.emitContext.EmitFlags(contextNode)
5921 loc, hasLoc := p.emitContext.TokenSourceMapRange(contextNode, token)
5922 if hasLoc {
5923 pos = loc.Pos()
5924 }
5925 if pos >= 0 && p.currentSourceFile != nil {
5926 pos = scanner.SkipTrivia(p.currentSourceFile.Text(), pos)
5927 }
5928 if emitFlags&EFNoTokenLeadingSourceMaps == 0 && pos >= 0 {
5929 p.emitSourcePos(p.sourceMapSource, pos)
5930 }
5931
5932 state := p.sourceMapStateArena.New()
5933 *state = sourceMapState{emitFlags, loc, hasLoc}
5934 return state
5935}
5936
5937func (p *Printer) emitSourceMapsAfterToken(token ast.Kind, pos int, contextNode *ast.Node, previousState *sourceMapState) {
5938 if previousState == nil {

Callers 1

enterTokenMethod · 0.95

Calls 8

emitSourcePosMethod · 0.95
SkipTriviaFunction · 0.92
EmitFlagsMethod · 0.80
TokenSourceMapRangeMethod · 0.80
NewMethod · 0.80
PosMethod · 0.65
TextMethod · 0.65

Tested by

no test coverage detected