@@ -21,15 +21,15 @@ const profile = {
21
21
documentation : 'https://remix-ide.readthedocs.io/en/latest/compile.html' ,
22
22
version : packageJson . version ,
23
23
maintainedBy : 'Remix' ,
24
- methods : [ 'getCompilationResult' , 'compile' , 'compileWithParameters' , 'setCompilerConfig' , 'compileFile' , 'getCompilerState' , 'getCompilerQueryParameters' , 'getCompiler' ]
24
+ methods : [ 'getCompilationResult' , 'compile' , 'compileWithParameters' , 'setCompilerConfig' , 'compileFile' , 'getCompilerState' , 'getCompilerConfig' , ' getCompilerQueryParameters', 'getCompiler' ]
25
25
}
26
26
27
27
// EditorApi:
28
28
// - events: ['compilationFinished'],
29
29
// - methods: ['getCompilationResult']
30
30
31
31
export default class CompileTab extends CompilerApiMixin ( ViewPlugin ) { // implements ICompilerApi
32
- constructor ( config , fileManager ) {
32
+ constructor ( config , fileManager ) {
33
33
super ( profile )
34
34
this . fileManager = fileManager
35
35
this . config = config
@@ -42,55 +42,55 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
42
42
this . el . setAttribute ( 'id' , 'compileTabView' )
43
43
}
44
44
45
- renderComponent ( ) {
45
+ renderComponent ( ) {
46
46
// empty method, is a state update needed?
47
47
}
48
48
49
- onCurrentFileChanged ( ) {
49
+ onCurrentFileChanged ( ) {
50
50
this . renderComponent ( )
51
51
}
52
52
53
53
// onResetResults () {
54
54
// this.renderComponent()
55
55
// }
56
56
57
- onSetWorkspace ( ) {
57
+ onSetWorkspace ( ) {
58
58
this . renderComponent ( )
59
59
}
60
60
61
- onFileRemoved ( ) {
61
+ onFileRemoved ( ) {
62
62
this . renderComponent ( )
63
63
}
64
64
65
- onNoFileSelected ( ) {
65
+ onNoFileSelected ( ) {
66
66
this . renderComponent ( )
67
67
}
68
68
69
- onFileClosed ( ) {
69
+ onFileClosed ( ) {
70
70
this . renderComponent ( )
71
71
}
72
72
73
- onCompilationFinished ( ) {
73
+ onCompilationFinished ( ) {
74
74
this . renderComponent ( )
75
75
}
76
76
77
- render ( ) {
78
- return < div id = 'compileTabView' > < SolidityCompiler api = { this } /> </ div >
77
+ render ( ) {
78
+ return < div id = 'compileTabView' > < SolidityCompiler api = { this } /> </ div >
79
79
}
80
80
81
- async compileWithParameters ( compilationTargets , settings ) {
81
+ async compileWithParameters ( compilationTargets , settings ) {
82
82
return await super . compileWithParameters ( compilationTargets , settings )
83
83
}
84
84
85
- getCompilationResult ( ) {
85
+ getCompilationResult ( ) {
86
86
return super . getCompilationResult ( )
87
87
}
88
88
89
- getFileManagerMode ( ) {
89
+ getFileManagerMode ( ) {
90
90
return this . fileManager . mode
91
91
}
92
92
93
- isDesktop ( ) {
93
+ isDesktop ( ) {
94
94
return Registry . getInstance ( ) . get ( 'platform' ) . api . isDesktop ( )
95
95
}
96
96
@@ -99,7 +99,7 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
99
99
* This function is used by remix-plugin compiler API.
100
100
* @param {object } settings {evmVersion, optimize, runs, version, language}
101
101
*/
102
- async setCompilerConfig ( settings ) {
102
+ async setCompilerConfig ( settings ) {
103
103
super . setCompilerConfig ( settings )
104
104
this . renderComponent ( )
105
105
// @todo (#2875) should use loading compiler return value to check whether the compiler is loaded instead of "setInterval"
@@ -108,20 +108,24 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
108
108
pluginInfo = await this . call ( 'udapp' , 'showPluginDetails' )
109
109
110
110
if ( this . currentRequest . from === 'udapp' ) {
111
- this . call ( 'notification' , 'toast' , compilerConfigChangedToastMsg ( ( pluginInfo ? pluginInfo . displayName : this . currentRequest . from ) , value ) )
111
+ this . call ( 'notification' , 'toast' , compilerConfigChangedToastMsg ( ( pluginInfo ? pluginInfo . displayName : this . currentRequest . from ) , value ) )
112
112
}
113
113
}
114
114
115
- compile ( fileName ) {
115
+ async getCompilerConfig ( ) {
116
+ return await super . getCompilerConfig ( )
117
+ }
118
+
119
+ compile ( fileName ) {
116
120
if ( ! isNative ( this . currentRequest . from ) ) this . call ( 'notification' , 'toast' , compileToastMsg ( this . currentRequest . from , fileName ) )
117
121
super . compile ( fileName )
118
122
}
119
123
120
- compileFile ( event ) {
124
+ compileFile ( event ) {
121
125
return super . compileFile ( event )
122
126
}
123
127
124
- async onActivation ( ) {
128
+ async onActivation ( ) {
125
129
super . onActivation ( )
126
130
this . on ( 'filePanel' , 'workspaceInitializationCompleted' , ( ) => {
127
131
this . call ( 'filePanel' , 'registerContextMenuItem' , {
@@ -134,6 +138,16 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
134
138
pattern : [ ] ,
135
139
group : 6
136
140
} )
141
+ this . on ( 'fileManager' , 'fileSaved' , async ( file ) => {
142
+ if ( await this . getAppParameter ( 'configFilePath' ) === file ) {
143
+ this . emit ( 'configFileChanged' , file )
144
+ }
145
+ } )
146
+ this . on ( 'fileManager' , 'fileAdded' , async ( file ) => {
147
+ if ( await this . getAppParameter ( 'configFilePath' ) === file ) {
148
+ this . emit ( 'configFileChanged' , file )
149
+ }
150
+ } )
137
151
} )
138
152
try {
139
153
this . currentFile = await this . call ( 'fileManager' , 'file' )
@@ -142,28 +156,38 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
142
156
}
143
157
}
144
158
145
- getCompiler ( ) {
159
+ getCompiler ( ) {
146
160
return this . compileTabLogic . compiler
147
161
}
148
162
149
- getCompilerQueryParameters ( ) {
163
+ getCompilerQueryParameters ( ) {
150
164
const params = this . queryParams . get ( )
151
165
params . evmVersion = params . evmVersion === 'null' || params . evmVersion === 'undefined' ? null : params . evmVersion
152
166
params . optimize = ( params . optimize === 'false' || params . optimize === null || params . optimize === undefined ) ? false : params . optimize
153
167
params . optimize = params . optimize === 'true' ? true : params . optimize
154
168
return params
155
169
}
156
170
157
- setCompilerQueryParameters ( params ) {
171
+ setCompilerQueryParameters ( params ) {
158
172
this . queryParams . update ( params )
173
+ try {
174
+ this . emit ( 'compilerQueryParamsUpdated' )
175
+ } catch ( e ) {
176
+ // do nothing
177
+ }
159
178
}
160
179
161
- async getAppParameter ( name ) {
180
+ async getAppParameter ( name ) {
162
181
return await this . call ( 'config' , 'getAppParameter' , name )
163
182
}
164
183
165
- async setAppParameter ( name , value ) {
184
+ async setAppParameter ( name , value ) {
166
185
await this . call ( 'config' , 'setAppParameter' , name , value )
186
+ try {
187
+ this . emit ( 'compilerAppParamsUpdated' )
188
+ } catch ( e ) {
189
+ // do nothing
190
+ }
167
191
}
168
192
}
169
193
0 commit comments