MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / atBlockEnd

Function atBlockEnd

src/extraction/languages/objcpp.ts:265–290  ·  view source on GitHub ↗
(at: number)

Source from the content-addressed store, hash-verified

263
264 /** The Objective-C block from the `@` at `at` through its `@end`; `#if` groups inside are counted. */
265 const atBlockEnd = (at: number): number => {
266 let lineStart = false;
267 for (let j = at + 1; j < n; ) {
268 const c = source.charCodeAt(j);
269 if (c === NEWLINE) {
270 lineStart = true;
271 j++;
272 } else if (isBlank(c)) j++;
273 else if (c === SLASH && source.charCodeAt(j + 1) === SLASH) j = lineCommentEnd(source, j + 2);
274 else if (c === SLASH && source.charCodeAt(j + 1) === STAR) {
275 const end = source.indexOf('*/', j + 2);
276 j = end < 0 ? n : end + 2;
277 } else if (c === HASH && lineStart) {
278 const name = directiveName(source, j);
279 if (CONDITIONAL_OPEN.has(name)) groups.push({ atIf: [], afterFirst: null, item: -2 });
280 else if (name === 'endif') groups.pop();
281 j = directiveEnd(source, j);
282 } else {
283 lineStart = false;
284 if (c === QUOTE || c === APOSTROPHE) j = quotedEnd(source, j);
285 else if (c === AT && source.startsWith('end', j + 1) && !isWordChar(source.charCodeAt(j + 4))) return j + 4;
286 else j++;
287 }
288 }
289 return n;
290 };
291
292 /**
293 * Read one item from `start`, its first comment or token; `lineStart` says

Callers 1

scanItemFunction · 0.85

Calls 8

isBlankFunction · 0.90
lineCommentEndFunction · 0.90
quotedEndFunction · 0.90
isWordCharFunction · 0.90
directiveNameFunction · 0.85
directiveEndFunction · 0.85
hasMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected