@@ -11,15 +11,14 @@ import type { SourceLocation } from "./core/types"
1111import {
1212 type EndpointTreeItem ,
1313 EndpointTreeProvider ,
14+ METHOD_ICONS ,
1415} from "./providers/endpointTreeProvider"
1516import { TestCodeLensProvider } from "./providers/testCodeLensProvider"
16- import { vscodeFileSystem } from "./providers/vscodeFileSystem"
1717import { disposeLogger , log } from "./utils/logger"
1818
1919let parserService : Parser | null = null
2020
2121function navigateToLocation ( location : SourceLocation ) : void {
22- // filePath is now a URI string, parse it back to vscode.Uri
2322 const uri = vscode . Uri . parse ( location . filePath )
2423 const position = new vscode . Position ( location . line - 1 , location . column )
2524 vscode . window . showTextDocument ( uri , {
@@ -138,6 +137,43 @@ function registerCommands(
138137 } ,
139138 ) ,
140139
140+ vscode . commands . registerCommand (
141+ "fastapi-vscode.searchEndpoints" ,
142+ async ( ) => {
143+ const workspacePrefix =
144+ vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ?? ""
145+ const items = endpointProvider
146+ . getAllRoutes ( )
147+ . map ( ( route ) => {
148+ const path = stripLeadingDynamicSegments ( route . path )
149+ return {
150+ label : `$(${ METHOD_ICONS [ route . method ] } ) ${ route . method . toUpperCase ( ) } ${ path } ` ,
151+ description : route . functionName ,
152+ detail : vscode . Uri . parse ( route . location . filePath )
153+ . fsPath . replace ( workspacePrefix , "" )
154+ . replace ( / ^ \/ / , "" ) ,
155+ route,
156+ sortKey : `${ path } ${ route . method } ` ,
157+ }
158+ } )
159+ . sort ( ( a , b ) => a . sortKey . localeCompare ( b . sortKey ) )
160+
161+ if ( items . length === 0 ) {
162+ vscode . window . showInformationMessage (
163+ "No FastAPI endpoints found in the workspace." ,
164+ )
165+ return
166+ }
167+
168+ const selected = await vscode . window . showQuickPick ( items , {
169+ placeHolder : "Search FastAPI endpoints..." ,
170+ } )
171+ if ( selected ) {
172+ navigateToLocation ( selected . route . location )
173+ }
174+ } ,
175+ ) ,
176+
141177 vscode . commands . registerCommand (
142178 "fastapi-vscode.copyEndpointPath" ,
143179 ( item : EndpointTreeItem ) => {
0 commit comments