@@ -4,41 +4,48 @@ import { cljConnection } from './cljConnection';
44import { cljParser } from './cljParser' ;
55import { nreplClient } from './nreplClient' ;
66import { readBooleanConfiguration } from './utils' ;
7+ import { ClojureLintingProvider } from './clojureLintingProvider' ;
78
89function getAlertOnEvalResult ( ) {
910 return readBooleanConfiguration ( 'aletOnEval' ) ;
1011}
1112
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 ) ;
1415}
1516
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 ) ;
1819}
1920
2021export 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 [ ] > {
2425 return cljConnection . sessionForFilename ( fileName ) . then ( session => {
2526 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 ;
3237 } ) ;
3338}
3439
35- function evaluate ( outputChannel : vscode . OutputChannel , showResults : boolean ) : void {
40+ function evaluate ( outputChannel : vscode . OutputChannel , linter : ClojureLintingProvider , showResults : boolean ) : void {
3641 if ( ! cljConnection . isConnected ( ) ) {
3742 vscode . window . showWarningMessage ( 'You should connect to nREPL first to evaluate code.' ) ;
3843 return ;
3944 }
4045
4146 const editor = vscode . window . activeTextEditor ;
47+ linter . runLinter ( editor . document ) ;
48+
4249 const selection = editor . selection ;
4350 let text = editor . document . getText ( ) ;
4451 if ( ! selection . isEmpty ) {
@@ -52,7 +59,7 @@ function evaluate(outputChannel: vscode.OutputChannel, showResults: boolean): vo
5259 return handleError ( outputChannel , selection , showResults , respObjs [ 0 ] . session ) ;
5360
5461 return handleSuccess ( outputChannel , showResults , respObjs ) ;
55- } ) ;
62+ } ) ;
5663}
5764
5865export function handleError ( outputChannel : vscode . OutputChannel , selection : vscode . Selection , showResults : boolean , session : string ) : Promise < void > {
0 commit comments