1
1
"use strict" ;
2
2
import {
3
3
window ,
4
- workspace ,
5
4
Uri ,
6
5
StatusBarItem ,
7
6
StatusBarAlignment ,
8
7
LanguageClient ,
9
8
} from "../../ideApi/_IdeApi" ;
9
+ import { CompilationStatus } from "../../stringResources/languageServer" ;
10
10
import {
11
11
LanguageServerNotification ,
12
12
StatusbarStrings ,
@@ -15,6 +15,15 @@ import {
15
15
16
16
import { IStatusbarProvider } from "./IStatusbarProvider" ;
17
17
18
+ const COMPILATION_STATUS_MESSAGE_MAPPINGS = {
19
+ [ CompilationStatus . ParsingFailed ] : StatusbarStrings . ParsingFailed ,
20
+ [ CompilationStatus . ResolutionFailed ] : StatusbarStrings . ResolutionFailed ,
21
+ [ CompilationStatus . CompilationSucceeded ] : StatusbarStrings . CompilationSucceeded ,
22
+ [ CompilationStatus . VerificationStarted ] : StatusbarStrings . Verifying ,
23
+ [ CompilationStatus . VerificationSucceeded ] : StatusbarStrings . VerificationSucceeded ,
24
+ [ CompilationStatus . VerificationFailed ] : StatusbarStrings . VerificationFailed
25
+ } ;
26
+
18
27
/**
19
28
* This component adds additional information to the status bar like
20
29
* if the Dafny file is valid or not and how many errors were found.
@@ -46,6 +55,17 @@ export class StatusbarProvider implements IStatusbarProvider {
46
55
}
47
56
) ;
48
57
58
+ // Sent when there are any changes to the compilation status of a document.
59
+ languageServer . onNotification (
60
+ LanguageServerNotification . CompilationStatus ,
61
+ ( { uri, status } : { uri : string , status : CompilationStatus } ) => {
62
+ this . verificationMessage [ Uri . parse ( uri ) . toString ( ) ] =
63
+ COMPILATION_STATUS_MESSAGE_MAPPINGS [ status ] ;
64
+ this . update ( ) ;
65
+ }
66
+ ) ;
67
+
68
+ // TODO: Status message for Dafny 3.2, remove in the future.
49
69
// Sent when the verification of a document started
50
70
languageServer . onNotification (
51
71
LanguageServerNotification . VerificationStarted ,
@@ -55,7 +75,8 @@ export class StatusbarProvider implements IStatusbarProvider {
55
75
this . update ( ) ;
56
76
}
57
77
) ;
58
-
78
+
79
+ // TODO: Status messages for Dafny 3.2, remove in the future.
59
80
// Sent when the verification of a document completed
60
81
languageServer . onNotification (
61
82
LanguageServerNotification . VerificationCompleted ,
@@ -66,10 +87,6 @@ export class StatusbarProvider implements IStatusbarProvider {
66
87
this . update ( ) ;
67
88
}
68
89
) ;
69
-
70
- workspace . onDidChangeTextDocument ( event => {
71
- this . verificationMessage [ event . document . uri . toString ( ) ] = StatusbarStrings . NotVerified ;
72
- } ) ;
73
90
}
74
91
75
92
public dispose ( ) : void {
0 commit comments