File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 243
243
"type" : " boolean" ,
244
244
"default" : true ,
245
245
"description" : " Show message fields in document outline"
246
+ },
247
+ "tact.findUsages.scope" : {
248
+ "type" : " string" ,
249
+ "enum" : [
250
+ " workspace" ,
251
+ " everywhere"
252
+ ],
253
+ "enumDescriptions" : [
254
+ " Search only in workspace files (default)" ,
255
+ " Search everywhere including standard library"
256
+ ],
257
+ "default" : " workspace" ,
258
+ "description" : " Where to search when using Find Usages"
246
259
}
247
260
}
248
261
},
Original file line number Diff line number Diff line change @@ -868,7 +868,7 @@ connection.onInitialize(async (params: lsp.InitializeParams): Promise<lsp.Initia
868
868
869
869
connection . onRequest (
870
870
lsp . ReferencesRequest . type ,
871
- ( params : lsp . ReferenceParams ) : lsp . Location [ ] | null => {
871
+ async ( params : lsp . ReferenceParams ) : Promise < lsp . Location [ ] | null > => {
872
872
const uri = params . textDocument . uri
873
873
874
874
if ( uri . endsWith ( ".fif" ) ) {
@@ -900,6 +900,17 @@ connection.onInitialize(async (params: lsp.InitializeParams): Promise<lsp.Initia
900
900
const result = new Referent ( referenceNode , file ) . findReferences ( false )
901
901
if ( result . length === 0 ) return null
902
902
903
+ const settings = await getDocumentSettings ( file . uri )
904
+ if ( settings . findUsages . scope === "workspace" ) {
905
+ // filter out references from stdlib
906
+ return result
907
+ . filter ( value => ! value . file . fromStdlib && ! value . file . fromStubs )
908
+ . map ( value => ( {
909
+ uri : value . file . uri ,
910
+ range : asLspRange ( value . node ) ,
911
+ } ) )
912
+ }
913
+
903
914
return result . map ( value => ( {
904
915
uri : value . file . uri ,
905
916
range : asLspRange ( value . node ) ,
Original file line number Diff line number Diff line change 1
1
import { connection } from "@server/connection"
2
2
3
+ export type FindUsagesScope = "workspace" | "everywhere"
4
+
3
5
export interface TactSettings {
4
6
stdlib : {
5
7
path : string | null
6
8
}
9
+ findUsages : {
10
+ scope : FindUsagesScope
11
+ }
7
12
hints : {
8
13
types : boolean
9
14
parameters : boolean
@@ -47,6 +52,9 @@ const defaultSettings: TactSettings = {
47
52
stdlib : {
48
53
path : null ,
49
54
} ,
55
+ findUsages : {
56
+ scope : "workspace" ,
57
+ } ,
50
58
hints : {
51
59
types : true ,
52
60
parameters : true ,
@@ -93,6 +101,9 @@ function mergeSettings(vsSettings: Partial<TactSettings>): TactSettings {
93
101
stdlib : {
94
102
path : vsSettings . stdlib ?. path ?? defaultSettings . stdlib . path ,
95
103
} ,
104
+ findUsages : {
105
+ scope : vsSettings . findUsages ?. scope ?? defaultSettings . findUsages . scope ,
106
+ } ,
96
107
hints : {
97
108
types : vsSettings . hints ?. types ?? defaultSettings . hints . types ,
98
109
parameters : vsSettings . hints ?. parameters ?? defaultSettings . hints . parameters ,
You can’t perform that action at this time.
0 commit comments