MCPcopy
hub / github.com/witheve/Eve / runMode

Function runMode

src/codemirror.js:6818–6853  ·  view source on GitHub ↗
(cm, text, mode, state, f, lineClasses, forceToEnd)

Source from the content-addressed store, hash-verified

6816
6817 // Run the given mode's parser over a line, calling f for each token.
6818 function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
6819 var flattenSpans = mode.flattenSpans;
6820 if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
6821 var curStart = 0, curStyle = null;
6822 var stream = new StringStream(text, cm.options.tabSize), style;
6823 var inner = cm.options.addModeClass && [null];
6824 if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
6825 while (!stream.eol()) {
6826 if (stream.pos > cm.options.maxHighlightLength) {
6827 flattenSpans = false;
6828 if (forceToEnd) processLine(cm, text, state, stream.pos);
6829 stream.pos = text.length;
6830 style = null;
6831 } else {
6832 style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
6833 }
6834 if (inner) {
6835 var mName = inner[0].name;
6836 if (mName) style = "m-" + (style ? mName + " " + style : mName);
6837 }
6838 if (!flattenSpans || curStyle != style) {
6839 while (curStart < stream.start) {
6840 curStart = Math.min(stream.start, curStart + 50000);
6841 f(curStart, curStyle);
6842 }
6843 curStyle = style;
6844 }
6845 stream.start = stream.pos;
6846 }
6847 while (curStart < stream.pos) {
6848 // Webkit seems to refuse to render text nodes longer than 57444 characters
6849 var pos = Math.min(stream.pos, curStart + 50000);
6850 f(pos, curStyle);
6851 curStart = pos;
6852 }
6853 }
6854
6855 // Compute a style array (an array starting with a mode generation
6856 // -- for invalidation -- followed by pairs of end positions and

Callers 1

highlightLineFunction · 0.85

Calls 6

eolMethod · 0.95
extractLineClassesFunction · 0.85
callBlankLineFunction · 0.85
processLineFunction · 0.85
readTokenFunction · 0.85
fFunction · 0.70

Tested by

no test coverage detected