@@ -19,28 +19,34 @@ export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {
19
19
] ) . then ( ( [ classes , routines , methods ] ) => [ ...classes , ...routines , ...methods ] ) ;
20
20
}
21
21
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 [ ] > {
23
29
query = query . toUpperCase ( ) ;
24
30
query = `*${ query } *` ;
25
31
const library = query . replace ( / % ( \b \w + \b (? ! \. ) ) / , "%LIBRARY.$1" ) ;
26
32
const sql = `
27
33
SELECT TOP 10 Name ClassName FROM %Dictionary.ClassDefinition
28
34
WHERE %SQLUPPER Name %MATCHES ? OR %SQLUPPER Name %MATCHES ?` ;
29
- const api = new AtelierAPI ( ) ;
35
+ const api = this . getApi ( ) ;
30
36
const data = await api . actionQuery ( sql , [ library , query ] ) ;
31
37
return data . result . content . map ( ( { ClassName } ) => ( {
32
38
kind : vscode . SymbolKind . Class ,
33
39
location : {
34
- uri : new ClassDefinition ( ClassName ) . uri ,
40
+ uri : new ClassDefinition ( ClassName , undefined , api . ns ) . uri ,
35
41
} ,
36
42
name : ClassName ,
37
43
} ) ) ;
38
44
}
39
45
40
- public async byRoutines ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
46
+ private async byRoutines ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
41
47
query = `*${ query } *.mac,*${ query } *.int` ;
42
48
const sql = `CALL %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?)` ;
43
- const api = new AtelierAPI ( ) ;
49
+ const api = this . getApi ( ) ;
44
50
const direction = "1" ;
45
51
const orderBy = "1" ;
46
52
const systemFiles = "0" ;
@@ -52,22 +58,22 @@ export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {
52
58
return data . result . content . map ( ( { Name } : StudioOpenDialog ) => ( {
53
59
kind : vscode . SymbolKind . File ,
54
60
location : {
55
- uri : DocumentContentProvider . getUri ( Name ) ,
61
+ uri : DocumentContentProvider . getUri ( Name , undefined , api . ns ) ,
56
62
} ,
57
63
name : Name ,
58
64
} ) ) ;
59
65
}
60
66
61
- public async byMethods ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
67
+ private async byMethods ( query : string ) : Promise < vscode . SymbolInformation [ ] > {
68
+ const api = this . getApi ( ) ;
62
69
query = query . toUpperCase ( ) ;
63
70
query = `*${ query } *` ;
64
71
const getLocation = async ( className , name ) => {
65
- const classDef = new ClassDefinition ( className ) ;
72
+ const classDef = new ClassDefinition ( className , undefined , api . ns ) ;
66
73
return classDef . getMemberLocation ( name ) ;
67
74
} ;
68
75
const sql = `
69
76
SELECT TOP 10 Parent ClassName, Name FROM %Dictionary.MethodDefinition WHERE %SQLUPPER Name %MATCHES ?` ;
70
- const api = new AtelierAPI ( ) ;
71
77
return api
72
78
. actionQuery ( sql , [ query ] )
73
79
. then ( ( data ) : Promise < vscode . SymbolInformation > [ ] =>
0 commit comments