Files
metabuilder/tools/refactoring/languages/cpp-refactor/functions/extract-dependencies.ts
T
copilot-swe-agent[bot] 4db87be546 Changes before error encountered
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 19:33:03 +00:00

27 lines
755 B
TypeScript

import * as fs from 'fs/promises'
import * as path from 'path'
import { DependencyInfo, FunctionInfo, RefactorResult } from './types'
export async function extractDependencies(filePath: string): Promise<DependencyInfo> {
const content = await fs.readFile(filePath, 'utf-8')
const lines = content.split('\n')
const imports: string[] = []
const types: string[] = []
for (const line of lines) {
const trimmed = line.trim()
if (trimmed.startsWith('#include')) {
imports.push(line)
}
if (trimmed.startsWith('struct ') || trimmed.startsWith('class ') ||
trimmed.startsWith('using ') || trimmed.startsWith('typedef ')) {
types.push(line)
}
}
return { imports, types }
}