@imenam/refactoring-mcp 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/utils/outline.js +29 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -130,6 +130,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
130
130
|
name: "get_file_outline",
|
|
131
131
|
description: "Retourne la liste des symboles d'un fichier (fonctions, classes, interfaces, types, constantes, méthodes) " +
|
|
132
132
|
"avec leurs numéros de lignes de début et de fin, et leur profondeur d'imbrication (depth). " +
|
|
133
|
+
"Si un bloc de commentaire JSDoc (/** ... */) précède immédiatement un symbole, les champs commentStartLine et commentEndLine sont inclus dans la réponse. " +
|
|
133
134
|
"Supporte tous les langages à accolades (TypeScript, JavaScript, PHP, Java, C#…). " +
|
|
134
135
|
"Paramètres optionnels : depth pour filtrer par niveau d'imbrication, startLine/endLine pour cibler une section. " +
|
|
135
136
|
"Le chemin doit être absolu.",
|
package/dist/utils/outline.js
CHANGED
|
@@ -33,6 +33,26 @@ const SYMBOL_PATTERNS = [
|
|
|
33
33
|
type: "method",
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
|
+
function findPrecedingComment(lines, symbolLineIndex) {
|
|
37
|
+
let idx = symbolLineIndex - 1;
|
|
38
|
+
while (idx >= 0 && lines[idx].trim() === "") {
|
|
39
|
+
idx--;
|
|
40
|
+
}
|
|
41
|
+
if (idx < 0)
|
|
42
|
+
return null;
|
|
43
|
+
const trimmed = lines[idx].trim();
|
|
44
|
+
if (!trimmed.endsWith("*/"))
|
|
45
|
+
return null;
|
|
46
|
+
const commentEndLine = idx + 1;
|
|
47
|
+
while (idx >= 0) {
|
|
48
|
+
const t = lines[idx].trim();
|
|
49
|
+
if (t.startsWith("/**") || t.startsWith("/*")) {
|
|
50
|
+
return { commentStartLine: idx + 1, commentEndLine };
|
|
51
|
+
}
|
|
52
|
+
idx--;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
36
56
|
function countBracesInLine(line) {
|
|
37
57
|
let count = 0;
|
|
38
58
|
let inSingleQuote = false;
|
|
@@ -78,7 +98,15 @@ export async function getFileOutline(filePath, options = {}) {
|
|
|
78
98
|
// Pour le pattern TS method, le groupe capturant est match[2] (match[1] = lookahead interne)
|
|
79
99
|
const name = match[2] ?? match[1];
|
|
80
100
|
if (name) {
|
|
81
|
-
|
|
101
|
+
const comment = findPrecedingComment(lines, i);
|
|
102
|
+
symbols.push({
|
|
103
|
+
name,
|
|
104
|
+
type,
|
|
105
|
+
...(comment ?? {}),
|
|
106
|
+
startLine: lineNum,
|
|
107
|
+
endLine: 0,
|
|
108
|
+
depth: braceDepth,
|
|
109
|
+
});
|
|
82
110
|
break;
|
|
83
111
|
}
|
|
84
112
|
}
|
package/package.json
CHANGED