@@ -19,6 +19,45 @@ export default class Commands {
19
19
private provider : DafnyUiManager ;
20
20
private runner : DafnyRunner ;
21
21
22
+ // todo move this function
23
+ public static showReferences ( jsonArgs : string ) {
24
+ // todo rm any
25
+ function parsePosition ( p : any ) : vscode . Position {
26
+ return new vscode . Position ( p . Line , p . Character ) ;
27
+ }
28
+ function parseRange ( r : any ) : vscode . Range {
29
+ return new vscode . Range ( parsePosition ( r . Start ) , parsePosition ( r . End ) ) ;
30
+ }
31
+ function parseLocation ( l : any ) : vscode . Location {
32
+ return new vscode . Location ( parseUri ( l . Uri ) , parseRange ( l . Range ) ) ;
33
+ }
34
+ function parseUri ( u : any ) : vscode . Uri {
35
+ return vscode . Uri . parse ( u ) ;
36
+ }
37
+
38
+ let obj ;
39
+ try {
40
+ obj = JSON . parse ( jsonArgs ) ;
41
+ } catch ( e ) {
42
+ // todo show error msg
43
+ }
44
+
45
+ const parsedUri : vscode . Uri = parseUri ( obj . Uri ) ;
46
+ const parsedPosition : vscode . Position = parsePosition ( obj . Position ) ;
47
+ const parsedLocations : Array < vscode . Location > = [ ] ;
48
+
49
+ for ( const location of obj . Locations ) {
50
+ parsedLocations . push ( parseLocation ( location ) ) ;
51
+ }
52
+
53
+ vscode . commands . executeCommand (
54
+ "editor.action.showReferences" ,
55
+ parsedUri ,
56
+ parsedPosition ,
57
+ parsedLocations
58
+ ) ;
59
+ }
60
+
22
61
private commands = [
23
62
{
24
63
name : CommandStrings . Compile ,
@@ -47,6 +86,10 @@ export default class Commands {
47
86
callback : ( ) =>
48
87
this . provider . getCounterModelProvider ( ) . hideCounterModel ( ) ,
49
88
} ,
89
+ {
90
+ name : CommandStrings . ShowReferences ,
91
+ callback : Commands . showReferences ,
92
+ } ,
50
93
/* Please note that the command "RestartServer" is registered in dafnyLanguageServer for a higher cohesion */
51
94
52
95
{
0 commit comments