/
lzr
/
alfa_aspx-parser
Обзор
Документация
Войти
/
lzr
/
alfa_aspx-parser
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
utils/extract_methods.js
23 строки
774 B
ifandeev
научил работать с .cs файлами
28 июн 2024, 13:31
28 июн 2024, 13:31
2755258
Код
Авторство
О чём код?
function extractMethods(fileContent) { const methodRegex = /((public|protected|private|internal)\s+\w+\s+\w+\s*\([^)]*\)\s*\{(?:[^{}]|(?:\{(?:[^{}]|(?:\{[^{}]*\}))*\}))*\})/gs; const methods = []; let match; while ((match = methodRegex.exec(fileContent)) !== null) { const fullText = match[1]; const nameMatch = fullText.match(/(\w+)\s*\(/); const name = nameMatch ? nameMatch[1] : ''; const bodyStartIndex = fullText.indexOf('{') + 1; const bodyEndIndex = fullText.lastIndexOf('}'); const body = fullText.substring(bodyStartIndex, bodyEndIndex).trim(); methods.push({ fullText, name, body }); } return methods; } module.exports = {extractMethods}