31
31
import com .google .common .util .concurrent .ListenableFuture ;
32
32
import com .google .common .util .concurrent .ListeningExecutorService ;
33
33
import com .google .idea .blaze .base .model .primitives .Label ;
34
+ import com .google .idea .blaze .base .model .primitives .WorkspaceRoot ;
34
35
import com .google .idea .blaze .base .sync .data .BlazeProjectDataManager ;
35
36
import com .google .idea .blaze .base .sync .workspace .ArtifactLocationDecoder ;
36
37
import com .google .idea .blaze .java .fastbuild .FastBuildState .BuildOutput ;
@@ -248,20 +249,20 @@ public void after(List<? extends VFileEvent> events) {
248
249
.map (File ::new )
249
250
.collect (toImmutableSet ());
250
251
251
- ImmutableSet <File > changedProtoFiles =
252
+ ImmutableSet <File > changedNonCompilableFiles =
252
253
changedFilePaths .stream ()
253
- .filter (f -> f .endsWith (".proto" ))
254
+ .filter (f -> f .endsWith (".proto" ) || f . endsWith ( ".bazel" ) )
254
255
.map (File ::new )
255
256
.collect (toImmutableSet ());
256
257
257
258
// TODO(b/145386688): Access should be guarded by enclosing instance
258
259
// 'com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService' of 'data',
259
260
// which is not accessible in this scope
260
261
261
- if (!changedCompilableFiles .isEmpty () || !changedProtoFiles .isEmpty ()) {
262
+ if (!changedCompilableFiles .isEmpty () || !changedNonCompilableFiles .isEmpty ()) {
262
263
labelData .values ()
263
264
.forEach (data -> data .updateChangedSources (changedCompilableFiles ,
264
- changedProtoFiles ));
265
+ changedNonCompilableFiles ));
265
266
}
266
267
267
268
return null ;
@@ -309,6 +310,9 @@ private ImmutableSet<File> getSourceFilesRecursively(
309
310
Set <File > sourceFiles = new HashSet <>();
310
311
ArtifactLocationDecoder decoder =
311
312
projectDataManager .getBlazeProjectData ().getArtifactLocationDecoder ();
313
+
314
+ String workSpaceRootPath = WorkspaceRoot .fromProject (project ).directory ().getAbsolutePath ();
315
+
312
316
SuccessorsFunction <FastBuildBlazeData > graph = l -> getDependencies (blazeData , l );
313
317
Traverser .forGraph (graph )
314
318
.breadthFirst (data )
@@ -319,15 +323,24 @@ private ImmutableSet<File> getSourceFilesRecursively(
319
323
.map (decoder ::decode )
320
324
.filter (f -> f .getName ().endsWith (".java" ) || f .getName ().endsWith (".scala" ))
321
325
.forEach (sourceFiles ::add );
326
+ addBuildFile (sourceFiles , workSpaceRootPath , d .buildFilePath ());
322
327
} else if (d .protoInfo ().isPresent ()) {
323
328
d .protoInfo ().get ().sources ().stream ()
324
329
.map (decoder ::decode )
325
330
.forEach (sourceFiles ::add );
331
+ addBuildFile (sourceFiles , workSpaceRootPath , d .buildFilePath ());
326
332
}
327
333
});
328
334
return ImmutableSet .copyOf (sourceFiles );
329
335
}
330
336
337
+ private static void addBuildFile (Set <File > sourceFiles ,String workSpaceRootPath , String buildFilePath ) {
338
+ File buildFile = new File (workSpaceRootPath , buildFilePath );
339
+ if (buildFile .exists ()) {
340
+ sourceFiles .add (buildFile );
341
+ }
342
+ }
343
+
331
344
private static ImmutableSet <FastBuildBlazeData > getDependencies (
332
345
Map <Label , FastBuildBlazeData > map , FastBuildBlazeData labelData ) {
333
346
return labelData .dependencies ().stream ()
0 commit comments