MCPcopy Index your code
hub / github.com/DHTMLX/gantt / takeToken

Function takeToken

samples/common/codehighlight/codemirror.js:1182–1194  ·  view source on GitHub ↗
(cm, pos, precise, asArray)

Source from the content-addressed store, hash-verified

1180
1181 // Utility for getTokenAt and getLineTokens
1182 function takeToken(cm, pos, precise, asArray) {
1183 var doc = cm.doc, mode = doc.mode, style;
1184 pos = clipPos(doc, pos);
1185 var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
1186 var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
1187 if (asArray) { tokens = []; }
1188 while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
1189 stream.start = stream.pos;
1190 style = readToken(mode, stream, context.state);
1191 if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
1192 }
1193 return asArray ? tokens : new Token(stream, style, context.state)
1194 }
1195
1196 function extractLineClasses(type, output) {
1197 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