MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / enter

Method enter

src/cm/rainbowBrackets.ts:243–284  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

241 from: scanStart,
242 to: scanEnd,
243 enter(node) {
244 if (isSkipContext(node.name)) {
245 return false;
246 }
247
248 const name = node.name;
249 if (
250 name === "(" ||
251 name === "[" ||
252 name === "{" ||
253 name === ")" ||
254 name === "]" ||
255 name === "}"
256 ) {
257 const pos = node.from;
258
259 if (isOpeningBracket(name)) {
260 const colorIndex = openBrackets.length % marks.length;
261 if (isVisible(pos)) {
262 builder.add(pos, pos + 1, marks[colorIndex]);
263 }
264 openBrackets.push({ char: name, colorIndex });
265 } else {
266 const matchingOpen = CLOSING_TO_OPENING[name as ClosingBracket];
267 if (!matchingOpen) return;
268
269 for (let index = openBrackets.length - 1; index >= 0; index--) {
270 if (openBrackets[index].char !== matchingOpen) continue;
271
272 if (isVisible(pos)) {
273 builder.add(
274 pos,
275 pos + 1,
276 marks[openBrackets[index].colorIndex],
277 );
278 }
279 openBrackets.length = index;
280 break;
281 }
282 }
283 }
284 },
285 });
286
287 return builder.finish();

Callers

nothing calls this directly

Calls 3

isSkipContextFunction · 0.85
isOpeningBracketFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected