MCPcopy Create free account
hub / github.com/breck7/scroll / takeToken

Function takeToken

external/.scrollLibs.js:2640–2660  ·  view source on GitHub ↗
(cm, pos, precise, asArray)

Source from the content-addressed store, hash-verified

2638
2639 // Utility for getTokenAt and getLineTokens
2640 function takeToken(cm, pos, precise, asArray) {
2641 var doc = cm.doc,
2642 mode = doc.mode,
2643 style
2644 pos = clipPos(doc, pos)
2645 var line = getLine(doc, pos.line),
2646 context = getContextBefore(cm, pos.line, precise)
2647 var stream = new StringStream(line.text, cm.options.tabSize, context),
2648 tokens
2649 if (asArray) {
2650 tokens = []
2651 }
2652 while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
2653 stream.start = stream.pos
2654 style = readToken(mode, stream, context.state)
2655 if (asArray) {
2656 tokens.push(new Token(stream, style, copyState(doc.mode, context.state)))
2657 }
2658 }
2659 return asArray ? tokens : new Token(stream, style, context.state)
2660 }
2661
2662 function extractLineClasses(type, output) {
2663 if (type) {

Callers 1

addEditorMethodsFunction · 0.85

Calls 5

clipPosFunction · 0.85
getLineFunction · 0.85
getContextBeforeFunction · 0.85
readTokenFunction · 0.85
copyStateFunction · 0.85

Tested by

no test coverage detected