@@ -5,7 +5,7 @@ import { MSDOSplayer } from './MSDOS-player'
55import { Uri } from 'vscode' ;
66import * as nls from 'vscode-nls' ;
77const localize = nls . loadMessageBundle ( )
8- import { landiagnose } from './diagnose' ;
8+ import { landiagnose } from './language/ diagnose' ;
99export class runcode {
1010 private readonly extOutChannel : vscode . OutputChannel ;
1111 private readonly exturi :Uri
@@ -21,45 +21,45 @@ export class runcode{
2121 this . dosbox = new DOSBox ( )
2222 this . landiag = new landiagnose ( this . extOutChannel )
2323 }
24- private Openemu ( fileuri : Uri ) {
25- let openemumsg = localize ( "openemu.msg" , "\nMASM/TASM>>Open DOSBox:{0}" , fileuri . fsPath )
24+ private Openemu ( doc : vscode . TextDocument ) {
25+ let openemumsg = localize ( "openemu.msg" , "\nMASM/TASM>>Open DOSBox:{0}" , doc . fileName )
2626 this . extOutChannel . appendLine ( openemumsg ) ;
27- this . dosbox . openDOSBox ( this . _config , undefined , fileuri , )
27+ this . dosbox . openDOSBox ( this . _config , undefined , doc )
2828 }
2929 /**运行汇编代码的入口
3030 * 获取拓展的设置,并执行相应操作
3131 */
32- private Run ( fileuri : Uri ) {
33- let runmsg = localize ( "run.msg" , "\n{0}({1})>>Run:{2}" , this . _config . MASMorTASM , this . _config . DOSemu , fileuri . fsPath )
32+ private Run ( doc : vscode . TextDocument ) {
33+ let runmsg = localize ( "run.msg" , "\n{0}({1})>>Run:{2}" , this . _config . MASMorTASM , this . _config . DOSemu , doc . fileName )
3434 this . extOutChannel . appendLine ( runmsg ) ;
3535 switch ( this . _config . DOSemu ) {
36- case 'msdos player' : this . msdosplayer . PlayerASM ( this . _config , true , true , this . landiag , fileuri ) ; break ;
36+ case 'msdos player' : this . msdosplayer . PlayerASM ( this . _config , true , true , this . landiag , doc ) ; break ;
3737 case 'dosbox' :
3838 let text = 'x:\\boxasm.bat ' + this . _config . MASMorTASM + ' run ' + this . _config . boxrunbat
39- this . dosbox . openDOSBox ( this . _config , text , fileuri , this . landiag )
39+ this . dosbox . openDOSBox ( this . _config , text , doc , this . landiag )
4040 break ;
41- case 'auto' : this . msdosplayer . PlayerASM ( this . _config , true , false , this . landiag , fileuri ) ; break ;
41+ case 'auto' : this . msdosplayer . PlayerASM ( this . _config , true , false , this . landiag , doc ) ; break ;
4242 default : throw new Error ( "未指定emulator" ) ;
4343 }
4444 }
4545 /**调试程序
4646 * 获取拓展的设置并执行相应操作
4747 */
48- private Debug ( fileuri : Uri ) {
49- let debugmsg = localize ( "debug.msg" , "\n{0}({1})>>Debug:{2}" , this . _config . MASMorTASM , this . _config . DOSemu , fileuri . fsPath )
48+ private Debug ( doc : vscode . TextDocument ) {
49+ let debugmsg = localize ( "debug.msg" , "\n{0}({1})>>Debug:{2}" , this . _config . MASMorTASM , this . _config . DOSemu , doc . fileName )
5050 this . extOutChannel . appendLine ( debugmsg ) ;
5151 if ( this . _config . DOSemu == 'msdos player' && this . _config . MASMorTASM == 'MASM' ) {
52- this . msdosplayer . PlayerASM ( this . _config , false , true , this . landiag , fileuri )
52+ this . msdosplayer . PlayerASM ( this . _config , false , true , this . landiag , doc )
5353 }
5454 else if ( this . _config . DOSemu == 'auto' )
5555 {
5656 let inplayer :boolean = false
5757 if ( this . _config . MASMorTASM == 'MASM' ) inplayer = true
58- this . msdosplayer . PlayerASM ( this . _config , false , inplayer , this . landiag , fileuri )
58+ this . msdosplayer . PlayerASM ( this . _config , false , inplayer , this . landiag , doc )
5959 }
6060 else {
6161 let text = 'x:\\boxasm.bat ' + this . _config . MASMorTASM + ' debug'
62- this . dosbox . openDOSBox ( this . _config , text , fileuri , this . landiag )
62+ this . dosbox . openDOSBox ( this . _config , text , doc , this . landiag )
6363 }
6464 }
6565 public cleanalldiagnose ( ) {
@@ -73,20 +73,20 @@ export class runcode{
7373 public runcode ( command :string ) {
7474 let exturi = this . exturi
7575 vscode . workspace . onDidChangeConfiguration ( ( event ) => { this . _config = new Config ( exturi ) } , this . _config )
76- const fileuri = vscode . window . activeTextEditor ?. document . uri
77- if ( fileuri )
76+ let document = vscode . window . activeTextEditor ?. document
77+ if ( document )
7878 {
7979 if ( this . _config . savefirst && vscode . window . activeTextEditor ?. document . isDirty ) {
80- vscode . window . activeTextEditor ?. document . save ( ) . then ( ( ) => this . asmit ( command , fileuri ) )
80+ document . save ( ) . then ( ( ) => { if ( document ) this . asmit ( command , document ) } )
8181 }
82- else this . asmit ( command , fileuri )
82+ else this . asmit ( command , document )
8383 }
8484 }
85- private asmit ( command :string , fileuri : Uri ) {
85+ private asmit ( command :string , doc : vscode . TextDocument ) {
8686 switch ( command ) {
87- case 'opendosbox' :this . Openemu ( fileuri ) ; break
88- case 'run' :this . Run ( fileuri ) ; break
89- case 'debug' :this . Debug ( fileuri ) ; break
87+ case 'opendosbox' :this . Openemu ( doc ) ; break
88+ case 'run' :this . Run ( doc ) ; break
89+ case 'debug' :this . Debug ( doc ) ; break
9090 }
9191 }
9292}
0 commit comments