MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / takeToken

Function takeToken

static/libs/codemirror.js:1650–1662  ·  view source on GitHub ↗
(cm, pos, precise, asArray)

Source from the content-addressed store, hash-verified

1648
1649// Utility for getTokenAt and getLineTokens
1650function takeToken(cm, pos, precise, asArray) {
1651 var doc = cm.doc, mode = doc.mode, style;
1652 pos = clipPos(doc, pos);
1653 var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
1654 var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
1655 if (asArray) { tokens = []; }
1656 while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
1657 stream.start = stream.pos;
1658 style = readToken(mode, stream, context.state);
1659 if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
1660 }
1661 return asArray ? tokens : new Token(stream, style, context.state)
1662}
1663
1664function extractLineClasses(type, output) {
1665 if (type) { for (;;) {

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