@@ -4,41 +4,48 @@ import { cljConnection } from './cljConnection';
4
4
import { cljParser } from './cljParser' ;
5
5
import { nreplClient } from './nreplClient' ;
6
6
import { readBooleanConfiguration } from './utils' ;
7
+ import { ClojureLintingProvider } from './clojureLintingProvider' ;
7
8
8
9
function getAlertOnEvalResult ( ) {
9
10
return readBooleanConfiguration ( 'aletOnEval' ) ;
10
11
}
11
12
12
- export function clojureEval ( outputChannel : vscode . OutputChannel ) : void {
13
- evaluate ( outputChannel , false ) ;
13
+ export function clojureEval ( outputChannel : vscode . OutputChannel , linter : ClojureLintingProvider ) : void {
14
+ evaluate ( outputChannel , linter , false ) ;
14
15
}
15
16
16
- export function clojureEvalAndShowResult ( outputChannel : vscode . OutputChannel ) : void {
17
- evaluate ( outputChannel , true ) ;
17
+ export function clojureEvalAndShowResult ( outputChannel : vscode . OutputChannel , linter : ClojureLintingProvider ) : void {
18
+ evaluate ( outputChannel , linter , true ) ;
18
19
}
19
20
20
21
export function evaluateText ( outputChannel : vscode . OutputChannel ,
21
- showResults : boolean ,
22
- fileName : string ,
23
- text : string ) : Promise < any [ ] > {
22
+ showResults : boolean ,
23
+ fileName : string ,
24
+ text : string ) : Promise < any [ ] > {
24
25
return cljConnection . sessionForFilename ( fileName ) . then ( session => {
25
26
return ( fileName . length === 0 && session . type == 'ClojureScript' )
26
- // Piggieback's evalFile() ignores the text sent as part of the request
27
- // and just loads the whole file content from disk. So we use eval()
28
- // here, which as a drawback will give us a random temporary filename in
29
- // the stacktrace should an exception occur.
30
- ? nreplClient . evaluate ( text , session . id )
31
- : nreplClient . evaluateFile ( text , fileName , session . id ) ;
27
+ // Piggieback's evalFile() ignores the text sent as part of the request
28
+ // and just loads the whole file content from disk. So we use eval()
29
+ // here, which as a drawback will give us a random temporary filename in
30
+ // the stacktrace should an exception occur.
31
+ ? nreplClient . evaluate ( text , session . id )
32
+ : nreplClient . evaluateFile ( text , fileName , session . id ) ;
33
+ } ) . then ( result => {
34
+
35
+
36
+ return result ;
32
37
} ) ;
33
38
}
34
39
35
- function evaluate ( outputChannel : vscode . OutputChannel , showResults : boolean ) : void {
40
+ function evaluate ( outputChannel : vscode . OutputChannel , linter : ClojureLintingProvider , showResults : boolean ) : void {
36
41
if ( ! cljConnection . isConnected ( ) ) {
37
42
vscode . window . showWarningMessage ( 'You should connect to nREPL first to evaluate code.' ) ;
38
43
return ;
39
44
}
40
45
41
46
const editor = vscode . window . activeTextEditor ;
47
+ linter . runLinter ( editor . document ) ;
48
+
42
49
const selection = editor . selection ;
43
50
let text = editor . document . getText ( ) ;
44
51
if ( ! selection . isEmpty ) {
@@ -52,7 +59,7 @@ function evaluate(outputChannel: vscode.OutputChannel, showResults: boolean): vo
52
59
return handleError ( outputChannel , selection , showResults , respObjs [ 0 ] . session ) ;
53
60
54
61
return handleSuccess ( outputChannel , showResults , respObjs ) ;
55
- } ) ;
62
+ } ) ;
56
63
}
57
64
58
65
export function handleError ( outputChannel : vscode . OutputChannel , selection : vscode . Selection , showResults : boolean , session : string ) : Promise < void > {
0 commit comments