curtis
17小時前 0756bf12d10cf1b7f78c571de0a9ad69cbaeb7ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const fs = require('fs');
const path = require('path');
 
const sourceFile = 'CB_IMGPSScanImp.pas.bk';
const base_path = 'doc/curtis/prompt/scanimpl_analysis';
const remainingsFile = path.join(base_path, 'scanimpl_annalysis.remainings.txt');
 
const modules = [
  'ScannerController',
  'BusinessLogic',
  'ImageProcessor',
  'TransportManager',
  'UIView'
];
 
function validate() {
  const lines = fs.readFileSync(sourceFile, 'utf8').split('\n');
  const totalLines = lines.length;
  const allCapturedMethods = [];
 
  modules.forEach(mod => {
    const filePath = path.join(base_path, `scanimpl_annalysis.${mod}.json`);
    if (fs.existsSync(filePath)) {
      const methods = JSON.parse(fs.readFileSync(filePath, 'utf8'));
      allCapturedMethods.push(...methods);
    }
  });
 
  const coveredLines = new Uint8Array(totalLines + 1);
 
  allCapturedMethods.forEach(m => {
    const sourceLine = lines[m.lIndex - 1].trim();
    if (sourceLine !== m.matcher) {
      console.error(`Mismatch at line ${m.lIndex}: Expected "${m.matcher}", got "${sourceLine}"`);
    }
 
    for (let i = m.lIndex; i <= m.rIndex; i++) {
      coveredLines[i] = 1;
    }
  });
 
  let remainings = [];
  let start = -1;
  for (let i = 1; i <= totalLines; i++) {
    if (!coveredLines[i]) {
      if (start === -1) start = i;
    } else {
      if (start !== -1) {
        remainings.push({lIndex: start, rIndex: i - 1});
        start = -1;
      }
    }
  }
  if (start !== -1) remainings.push({lIndex: start, rIndex: totalLines});
 
  const remainingsText = remainings.map(r => {
    const content = lines.slice(r.lIndex - 1, r.rIndex).join('\n');
    return `[Lines ${r.lIndex} - ${r.rIndex}]\n${content}\n----------------------------------------\n`;
  }).join('\n');
 
  fs.writeFileSync(remainingsFile, remainingsText, 'utf8');
  console.log(`Validation complete. Remainings saved to ${remainingsFile}`);
}
 
validate();