(cm, pos, precise, asArray)
| 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) { |
no test coverage detected