@@ -34,7 +34,7 @@ import {
34
34
} from "../utils" ;
35
35
import { StudioActions } from "./studio" ;
36
36
import { NodeBase , PackageNode , RootNode } from "../explorer/nodes" ;
37
- import { updateIndexForDocument } from "../utils/documentIndex" ;
37
+ import { getUrisForDocument , updateIndexForDocument } from "../utils/documentIndex" ;
38
38
39
39
async function compileFlags ( ) : Promise < string > {
40
40
const defaultFlags = config ( ) . compileFlags ;
@@ -249,12 +249,11 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
249
249
}
250
250
251
251
export async function compile ( docs : CurrentFile [ ] , flags ?: string ) : Promise < any > {
252
- const conf = vscode . workspace . getConfiguration (
253
- "objectscript" ,
254
- vscode . workspace . getWorkspaceFolder ( docs [ 0 ] . uri ) || docs [ 0 ] . uri
255
- ) ;
252
+ const wsFolder = vscode . workspace . getWorkspaceFolder ( docs [ 0 ] . uri ) ;
253
+ const conf = vscode . workspace . getConfiguration ( "objectscript" , wsFolder || docs [ 0 ] . uri ) ;
256
254
flags = flags || conf . get ( "compileFlags" ) ;
257
255
const api = new AtelierAPI ( docs [ 0 ] . uri ) ;
256
+ const docNames = docs . map ( ( d ) => d . name ) ;
258
257
return vscode . window
259
258
. withProgress (
260
259
{
@@ -264,18 +263,31 @@ export async function compile(docs: CurrentFile[], flags?: string): Promise<any>
264
263
} ,
265
264
( progress , token : vscode . CancellationToken ) =>
266
265
api
267
- . asyncCompile (
268
- docs . map ( ( el ) => el . name ) ,
269
- token ,
270
- flags
271
- )
266
+ . asyncCompile ( docNames , token , flags )
272
267
. then ( ( data ) => {
273
268
const info = docs . length > 1 ? "" : `${ docs [ 0 ] . name } : ` ;
274
269
if ( data . status && data . status . errors && data . status . errors . length ) {
275
270
throw new Error ( `${ info } Compile error` ) ;
276
271
} else if ( ! conf . get ( "suppressCompileMessages" ) ) {
277
272
vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
278
273
}
274
+ if ( wsFolder ) {
275
+ // Make sure that we update the content for any
276
+ // other documents affected by this compilation
277
+ data . result . content . forEach ( ( f ) => {
278
+ if ( docNames . includes ( f . name ) ) return ;
279
+ getUrisForDocument ( f . name , wsFolder ) . forEach ( ( u ) => {
280
+ docs . push ( {
281
+ name : f . name ,
282
+ uri : u ,
283
+ uniqueId : `${ wsFolder . name } :${ f . name } ` ,
284
+ // These two keys aren't used by loadChanges()
285
+ workspaceFolder : wsFolder . name ,
286
+ fileName : u . fsPath ,
287
+ } ) ;
288
+ } ) ;
289
+ } ) ;
290
+ }
279
291
return docs ;
280
292
} )
281
293
. catch ( ( ) => {
0 commit comments