Repository navigation
Expand file tree
/
Copy pathdebug-current-issues.js
More file actions
100 lines (85 loc) · 3.28 KB
/
Copy pathdebug-current-issues.js
File metadata and controls
100 lines (85 loc) · 3.28 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// 调试当前问题
const fs = require('fs');
// 从extension.js复制的detectMethodContext函数
function detectMethodContext(lines, currentLineIndex, methodName) {
const context = {
type: 'module',
className: null,
fullName: methodName,
indentLevel: 0,
isClassMethod: false,
getFullName: function(name) {
if (this.className) {
return `${this.className}.${name}`;
}
return name;
}
};
const currentLine = lines[currentLineIndex];
const indentMatch = currentLine.match(/^(\s*)/);
if (indentMatch) {
context.indentLevel = indentMatch[1].length;
}
for (let i = currentLineIndex - 1; i >= 0; i--) {
const line = lines[i];
if (line.trim() === '' || line.trim().startsWith('#')) {
continue;
}
const classMatch = line.match(/^\s*class\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
if (classMatch) {
const classIndentMatch = line.match(/^(\s*)/);
const classIndentLevel = classIndentMatch ? classIndentMatch[1].length : 0;
if (classIndentLevel < context.indentLevel) {
context.type = 'class';
context.className = classMatch[1];
context.isClassMethod = true;
context.fullName = `${context.className}.${methodName}`;
break;
}
}
const lineIndentMatch = line.match(/^(\s*)/);
const lineIndentLevel = lineIndentMatch ? lineIndentMatch[1].length : 0;
if (lineIndentLevel <= context.indentLevel && line.trim() !== '') {
break;
}
}
return context;
}
// 检查method2的具体情况
function debugMethod2() {
const content = fs.readFileSync('/Users/liqilin/PycharmProjects/vs code/Admin-Method-Duplicate-Check/debug_test.py', 'utf8');
const lines = content.split('\n');
console.log('=== 调试method2问题 ===\n');
// 查找所有method2
const method2Lines = [];
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('def method2')) {
method2Lines.push({
lineNumber: i + 1,
content: lines[i].trim(),
context: detectMethodContext(lines, i, 'method2')
});
}
}
console.log('找到的method2方法:');
method2Lines.forEach(method => {
console.log(`第${method.lineNumber}行: "${method.content}"`);
console.log(` 完整限定名: ${method.context.fullName}`);
console.log(` 类型: ${method.context.type}`);
console.log(` 类名: ${method.context.className || '无'}`);
console.log(` 缩进级别: ${method.context.indentLevel}`);
console.log('');
});
// 检查上下文检测是否正确
console.log('=== 上下文检测验证 ===');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('class TestClass')) {
console.log(`第${i + 1}行: "${line.trim()}"`);
const indentMatch = line.match(/^(\s*)/);
console.log(` 缩进: ${indentMatch ? indentMatch[1].length : 0} 个空格`);
}
}
return method2Lines;
}
debugMethod2();