Skip to content

Commit 5601915

Browse files
committed
feat(file-read): add support for extracting orphaned content and enhance read functionality
1 parent c0ee565 commit 5601915

2 files changed

Lines changed: 406 additions & 102 deletions

File tree

src/client-pipe.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,32 @@ export interface FileExecuteRenameResult {
759759
error?: string;
760760
}
761761

762+
// ── Orphaned Content Types ─────────────────────────────────
763+
764+
export interface OrphanedSymbolNode {
765+
name: string;
766+
kind: string;
767+
detail?: string;
768+
range: {start: number; end: number};
769+
children?: OrphanedSymbolNode[];
770+
}
771+
772+
export interface OrphanedContentResult {
773+
imports: OrphanedSymbolNode[];
774+
exports: OrphanedSymbolNode[];
775+
orphanComments: OrphanedSymbolNode[];
776+
directives: OrphanedSymbolNode[];
777+
gaps: Array<{start: number; end: number; type: 'blank' | 'unknown'}>;
778+
stats: {
779+
totalImports: number;
780+
totalExports: number;
781+
totalOrphanComments: number;
782+
totalDirectives: number;
783+
totalBlankLines: number;
784+
coveragePercent: number;
785+
};
786+
}
787+
762788
export interface FileFindReferencesResult {
763789
references: Array<{file: string; line: number; character: number}>;
764790
}
@@ -927,6 +953,23 @@ export async function fileApplyCodeAction(
927953
return result;
928954
}
929955

956+
/**
957+
* Extract orphaned content (imports, exports, comments) from TypeScript/JavaScript files.
958+
* Supplements VS Code's DocumentSymbol API which doesn't include these constructs.
959+
*/
960+
export async function fileExtractOrphanedContent(
961+
filePath: string,
962+
includeSymbols = true,
963+
): Promise<OrphanedContentResult> {
964+
const result = await sendClientRequest(
965+
'file.extractOrphanedContent',
966+
{filePath, includeSymbols},
967+
30_000,
968+
);
969+
assertResult<OrphanedContentResult>(result, 'file.extractOrphanedContent');
970+
return result;
971+
}
972+
930973
// ── Recovery Handler ─────────────────────────────────────
931974

932975
let clientRecoveryHandler: (() => Promise<void>) | undefined;

0 commit comments

Comments
 (0)