MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / dispatch

Function dispatch

lib/web/CodeMirror/mode/php/php.js:157–192  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

155 var phpMode = CodeMirror.getMode(config, phpConfig);
156
157 function dispatch(stream, state) {
158 var isPHP = state.curMode == phpMode;
159 if (stream.sol() && state.pending && state.pending != '"' && state.pending != "'") state.pending = null;
160 if (!isPHP) {
161 if (stream.match(/^<\?\w*/)) {
162 state.curMode = phpMode;
163 if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "", ""))
164 state.curState = state.php;
165 return "meta";
166 }
167 if (state.pending == '"' || state.pending == "'") {
168 while (!stream.eol() && stream.next() != state.pending) {}
169 var style = "string";
170 } else if (state.pending && stream.pos < state.pending.end) {
171 stream.pos = state.pending.end;
172 var style = state.pending.style;
173 } else {
174 var style = htmlMode.token(stream, state.curState);
175 }
176 if (state.pending) state.pending = null;
177 var cur = stream.current(), openPHP = cur.search(/<\?/), m;
178 if (openPHP != -1) {
179 if (style == "string" && (m = cur.match(/[\'\"]$/)) && !/\?>/.test(cur)) state.pending = m[0];
180 else state.pending = {end: stream.pos, style: style};
181 stream.backUp(cur.length - openPHP);
182 }
183 return style;
184 } else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
185 state.curMode = htmlMode;
186 state.curState = state.html;
187 if (!state.php.context.prev) state.php = null;
188 return "meta";
189 } else {
190 return phpMode.token(stream, state.curState);
191 }
192 }
193
194 return {
195 startState: function() {

Callers

nothing calls this directly

Calls 9

solMethod · 0.80
eolMethod · 0.80
currentMethod · 0.80
backUpMethod · 0.80
nextMethod · 0.65
matchMethod · 0.45
indentMethod · 0.45
searchMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected