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

Function directiveEnd

src/extraction/languages/objcpp.ts:183–205  ·  view source on GitHub ↗

The end of the preprocessor line that starts at `i`, through `\` continuations and comments.

(source: string, i: number)

Source from the content-addressed store, hash-verified

181
182/** The end of the preprocessor line that starts at `i`, through `\` continuations and comments. */
183function directiveEnd(source: string, i: number): number {
184 const n = source.length;
185 let j = i + 1;
186 while (j < n) {
187 const d = source.charCodeAt(j);
188 if (d === NEWLINE) {
189 let k = j - 1;
190 if (source.charCodeAt(k) === 13) k--;
191 if (source.charCodeAt(k) !== 92) break;
192 j++;
193 } else if (d === SLASH && source.charCodeAt(j + 1) === SLASH) {
194 j = lineCommentEnd(source, j + 2);
195 } else if (d === SLASH && source.charCodeAt(j + 1) === STAR) {
196 const end = source.indexOf('*/', j + 2);
197 j = end < 0 ? n : end + 2;
198 } else if (d === QUOTE) {
199 j = quotedEnd(source, j);
200 } else {
201 j++;
202 }
203 }
204 return j;
205}
206
207/** The name of the directive whose `#` is at `i` (`if`, `import`, `endif`). */
208function directiveName(source: string, i: number): string {

Callers 2

atBlockEndFunction · 0.85
scanItemFunction · 0.85

Calls 2

lineCommentEndFunction · 0.90
quotedEndFunction · 0.90

Tested by

no test coverage detected