@@ -2,17 +2,21 @@ import { languages, workspace } from "vscode";
2
2
import { getSqlDocument } from "./logic/parse" ;
3
3
import { JobManager } from "../../config" ;
4
4
import Statement from "../../database/statement" ;
5
- import { StatementType } from "../sql/types" ;
6
5
import { remoteAssistIsEnabled } from "./logic/available" ;
7
- import Schemas , { AllSQLTypes , InternalTypes , SQLType } from "../../database/schemas" ;
6
+ import Schemas , { } from "../../database/schemas" ;
8
7
9
8
10
9
export const peekProvider = languages . registerDefinitionProvider ( { language : `sql` } , {
11
10
async provideDefinition ( document , position , token ) {
12
- const standardObjects : SQLType [ ] = AllSQLTypes . filter ( type => ! [ `functions` , `procedures` ] . includes ( type ) ) ;
13
11
if ( ! remoteAssistIsEnabled ( ) ) return ;
14
12
15
- const defaultSchema = getDefaultSchema ( ) ;
13
+ const currentJob = JobManager . getSelection ( ) ;
14
+
15
+ if ( ! currentJob ) return ;
16
+
17
+ const defaultSchema = currentJob . job . getCurrentSchema ( ) ;
18
+ const naming = currentJob . job . getNaming ( ) ;
19
+
16
20
const sqlDoc = getSqlDocument ( document ) ;
17
21
const offset = document . offsetAt ( position ) ;
18
22
@@ -26,7 +30,13 @@ export const peekProvider = languages.registerDefinitionProvider({ language: `sq
26
30
27
31
if ( ref ) {
28
32
const name = Statement . noQuotes ( Statement . delimName ( ref . object . name , true ) ) ;
29
- const schema = ref . object . schema ? Statement . noQuotes ( Statement . delimName ( ref . object . schema , true ) ) : undefined ;
33
+
34
+ // Schema is based on a few things:
35
+ // If it's a fully qualified path, use the schema path
36
+ // Otherwise:
37
+ // - if SQL naming is in use, then use the default schema
38
+ // - if system naming is in use, then don't pass a library and the library list will be used
39
+ const schema = ref . object . schema ? Statement . noQuotes ( Statement . delimName ( ref . object . schema , true ) ) : naming === `sql` ? defaultSchema : undefined ;
30
40
31
41
const possibleObjects = await Schemas . resolveObjects ( [ { name, schema} ] ) ;
32
42
@@ -45,9 +55,4 @@ export const peekProvider = languages.registerDefinitionProvider({ language: `sq
45
55
}
46
56
}
47
57
}
48
- } ) ;
49
-
50
- const getDefaultSchema = ( ) : string => {
51
- const currentJob = JobManager . getSelection ( ) ;
52
- return currentJob && currentJob . job . options . libraries [ 0 ] ? currentJob . job . options . libraries [ 0 ] : `QGPL` ;
53
- }
58
+ } ) ;
0 commit comments