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

Function checkCppPass

src/extraction/objcpp-extractor.ts:60–89  ·  view source on GitHub ↗

* What the C++ pass made of each C++ item: `misread`, the items the grammar * misread, by their start (one whose symbols run past its end, and a function * body's item with no function that ends at its `}`), and `found`, how many * symbols each item gave. Null when the pass can't be used at all.

(
  cpp: ExtractionResult,
  parts: ObjcppParts,
  offsetOf: (line: number, column: number) => number
)

Source from the content-addressed store, hash-verified

58 * symbols each item gave. Null when the pass can't be used at all.
59 */
60function checkCppPass(
61 cpp: ExtractionResult,
62 parts: ObjcppParts,
63 offsetOf: (line: number, column: number) => number
64): { misread: Set<number>; found: Uint32Array } | null {
65 if (cpp.errors.some((error) => error.severity === 'error')) return null;
66 const items = parts.items;
67 const itemStarts = items.map((item) => item.start);
68 const hasFunction = new Uint8Array(items.length);
69 const found = new Uint32Array(items.length);
70 const misread = new Set<number>();
71 for (const node of cpp.nodes) {
72 if (node.kind === 'file') continue;
73 const start = offsetOf(node.startLine, node.startColumn);
74 const end = offsetOf(node.endLine, node.endColumn);
75 const k = lastStartingBefore(itemStarts, start);
76 if (k < 0 || start >= items[k]!.end) return null;
77 const item = items[k]!;
78 found[k]!++;
79 if (end > item.end) misread.add(item.start);
80 if (item.bodyEnd >= 0 && hasFunction[k] === 0 && (node.kind === 'function' || node.kind === 'method')) {
81 hasFunction[k] = 1;
82 if (end !== item.bodyEnd) misread.add(item.start);
83 }
84 }
85 for (let k = 0; k < items.length; k++) {
86 if (items[k]!.bodyEnd >= 0 && hasFunction[k] === 0) misread.add(items[k]!.start);
87 }
88 return { misread, found };
89}
90
91/**
92 * Extract an Objective-C++ file. `run` extracts a source with one grammar, as

Callers 1

extractObjcppFunction · 0.85

Calls 4

lastStartingBeforeFunction · 0.85
mapMethod · 0.80
offsetOfFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected