@@ -23,6 +23,7 @@ const activate = context => {
23
23
return {
24
24
25
25
init,
26
+ get : ( option ) => options . get ( option ) ,
26
27
conn : ( ) => {
27
28
const _conn = options . get ( 'conn' )
28
29
_conn . toString = ( ) => JSON . stringify ( Object . assign ( { } , _conn , { password : '***' } ) , null , 4 )
@@ -57,12 +58,21 @@ const activate = context => {
57
58
58
59
} , null , context . subscriptions ) //reload config on event
59
60
61
+ workspace . onDidSaveTextDocument ( ( file ) => {
62
+ if ( ! config . get ( 'autoCompile' ) ) {
63
+ return
64
+ }
65
+ if ( languages . includes ( file . languageId ) ) {
66
+ importCompileExport ( ) ;
67
+ }
68
+ } )
69
+
60
70
const currentDoc = CurrentDoc ( { window, languages, log } )
61
71
62
72
const Save = ( { name, log, fileName } ) => ( err , data ) => {
63
73
64
74
// IsApiError, ExportDoc - global
65
- const isGetDocError = IsApiError ( name , 'getDoc' , log )
75
+ const isGetDocError = IsApiError ( name , 'getDoc' , log , window )
66
76
if ( isGetDocError ( { err, data } ) ) return
67
77
68
78
const completed = ( ) => log ( 'Completed.' )
@@ -73,7 +83,7 @@ const activate = context => {
73
83
74
84
const Export = ( { api, name, log, fileName } ) => ( err , data ) => {
75
85
// IsApiError, Save - from upper scope
76
- const isCompileError = IsApiError ( name , 'compile' , log )
86
+ const isCompileError = IsApiError ( name , 'compile' , log , window )
77
87
if ( isCompileError ( { err, data } ) ) return ;
78
88
// after compilation API returns updated storage definition
79
89
// but, currently, we don`t have any AST implementation
@@ -87,13 +97,13 @@ const activate = context => {
87
97
const Compile = ( { api, name, log, fileName } ) => ( err , data ) => {
88
98
89
99
// IsApiError, Export
90
- const isImportError = IsApiError ( name , 'import' , log )
100
+ const isImportError = IsApiError ( name , 'import' , log , window )
91
101
if ( isImportError ( { err, data } ) ) return ;
92
102
93
103
const exportCurrent = Export ( { api, name, log, fileName } )
94
104
//log( `Compile ${ name }` )
95
105
api . compile ( name , exportCurrent )
96
-
106
+ window . showInformationMessage ( ` ${ name } : Compile successed` )
97
107
}
98
108
99
109
// import -> compile -> export
0 commit comments