mirror of
https://github.com/harivansh-afk/evaluclaude-harness.git
synced 2026-04-19 11:03:46 +00:00
iteration 0
This commit is contained in:
commit
4b24606d0e
25 changed files with 7843 additions and 0 deletions
29
src/introspector/parsers/base.ts
Normal file
29
src/introspector/parsers/base.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import type { ModuleInfo, ExportInfo } from '../types.js';
|
||||
|
||||
export interface ParserResult {
|
||||
exports: ExportInfo[];
|
||||
imports: string[];
|
||||
}
|
||||
|
||||
export abstract class BaseParser {
|
||||
abstract readonly language: string;
|
||||
|
||||
abstract parse(source: string, filePath: string): ModuleInfo;
|
||||
|
||||
protected getText(source: string, startIndex: number, endIndex: number): string {
|
||||
return source.slice(startIndex, endIndex);
|
||||
}
|
||||
|
||||
protected calculateComplexity(exportCount: number): ModuleInfo['complexity'] {
|
||||
if (exportCount <= 5) return 'low';
|
||||
if (exportCount <= 15) return 'medium';
|
||||
return 'high';
|
||||
}
|
||||
|
||||
protected extractFirstLineOfDocstring(docstring: string | undefined): string | undefined {
|
||||
if (!docstring) return undefined;
|
||||
const trimmed = docstring.trim();
|
||||
const firstLine = trimmed.split('\n')[0];
|
||||
return firstLine.replace(/^["']{1,3}|["']{1,3}$/g, '').trim() || undefined;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue