@@ -19,28 +19,34 @@ export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {
1919 ] ) . then ( ( [ classes , routines , methods ] ) => [ ...classes , ...routines , ...methods ] ) ;
2020 }
2121
22- public async byClasses ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
22+ private getApi ( ) : AtelierAPI {
23+ const currentFileUri = vscode . window . activeTextEditor ?. document . uri ;
24+ const firstFolder = vscode . workspace . workspaceFolders ?. length ? vscode . workspace . workspaceFolders [ 0 ] : undefined ;
25+ return new AtelierAPI ( currentFileUri || firstFolder ?. uri || "" ) ;
26+ }
27+
28+ private async byClasses ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
2329 query = query . toUpperCase ( ) ;
2430 query = `*${ query } *` ;
2531 const library = query . replace ( / % ( \b \w + \b (? ! \. ) ) / , "%LIBRARY.$1" ) ;
2632 const sql = `
2733 SELECT TOP 10 Name ClassName FROM %Dictionary.ClassDefinition
2834 WHERE %SQLUPPER Name %MATCHES ? OR %SQLUPPER Name %MATCHES ?` ;
29- const api = new AtelierAPI ( ) ;
35+ const api = this . getApi ( ) ;
3036 const data = await api . actionQuery ( sql , [ library , query ] ) ;
3137 return data . result . content . map ( ( { ClassName } ) => ( {
3238 kind : vscode . SymbolKind . Class ,
3339 location : {
34- uri : new ClassDefinition ( ClassName ) . uri ,
40+ uri : new ClassDefinition ( ClassName , undefined , api . ns ) . uri ,
3541 } ,
3642 name : ClassName ,
3743 } ) ) ;
3844 }
3945
40- public async byRoutines ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
46+ private async byRoutines ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
4147 query = `*${ query } *.mac,*${ query } *.int` ;
4248 const sql = `CALL %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?)` ;
43- const api = new AtelierAPI ( ) ;
49+ const api = this . getApi ( ) ;
4450 const direction = "1" ;
4551 const orderBy = "1" ;
4652 const systemFiles = "0" ;
@@ -52,22 +58,22 @@ export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {
5258 return data . result . content . map ( ( { Name } : StudioOpenDialog ) => ( {
5359 kind : vscode . SymbolKind . File ,
5460 location : {
55- uri : DocumentContentProvider . getUri ( Name ) ,
61+ uri : DocumentContentProvider . getUri ( Name , undefined , api . ns ) ,
5662 } ,
5763 name : Name ,
5864 } ) ) ;
5965 }
6066
61- public async byMethods ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
67+ private async byMethods ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
68+ const api = this . getApi ( ) ;
6269 query = query . toUpperCase ( ) ;
6370 query = `*${ query } *` ;
6471 const getLocation = async ( className , name ) => {
65- const classDef = new ClassDefinition ( className ) ;
72+ const classDef = new ClassDefinition ( className , undefined , api . ns ) ;
6673 return classDef . getMemberLocation ( name ) ;
6774 } ;
6875 const sql = `
6976 SELECT TOP 10 Parent ClassName, Name FROM %Dictionary.MethodDefinition WHERE %SQLUPPER Name %MATCHES ?` ;
70- const api = new AtelierAPI ( ) ;
7177 return api
7278 . actionQuery ( sql , [ query ] )
7379 . then ( ( data ) : Promise < vscode . SymbolInformation > [ ] =>
0 commit comments