3131import com .google .common .util .concurrent .ListenableFuture ;
3232import com .google .common .util .concurrent .ListeningExecutorService ;
3333import com .google .idea .blaze .base .model .primitives .Label ;
34+ import com .google .idea .blaze .base .model .primitives .WorkspaceRoot ;
3435import com .google .idea .blaze .base .sync .data .BlazeProjectDataManager ;
3536import com .google .idea .blaze .base .sync .workspace .ArtifactLocationDecoder ;
3637import com .google .idea .blaze .java .fastbuild .FastBuildState .BuildOutput ;
@@ -248,20 +249,20 @@ public void after(List<? extends VFileEvent> events) {
248249 .map (File ::new )
249250 .collect (toImmutableSet ());
250251
251- ImmutableSet <File > changedProtoFiles =
252+ ImmutableSet <File > changedNonCompilableFiles =
252253 changedFilePaths .stream ()
253- .filter (f -> f .endsWith (".proto" ))
254+ .filter (f -> f .endsWith (".proto" ) || f . endsWith ( ".bazel" ) )
254255 .map (File ::new )
255256 .collect (toImmutableSet ());
256257
257258 // TODO(b/145386688): Access should be guarded by enclosing instance
258259 // 'com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService' of 'data',
259260 // which is not accessible in this scope
260261
261- if (!changedCompilableFiles .isEmpty () || !changedProtoFiles .isEmpty ()) {
262+ if (!changedCompilableFiles .isEmpty () || !changedNonCompilableFiles .isEmpty ()) {
262263 labelData .values ()
263264 .forEach (data -> data .updateChangedSources (changedCompilableFiles ,
264- changedProtoFiles ));
265+ changedNonCompilableFiles ));
265266 }
266267
267268 return null ;
@@ -309,6 +310,9 @@ private ImmutableSet<File> getSourceFilesRecursively(
309310 Set <File > sourceFiles = new HashSet <>();
310311 ArtifactLocationDecoder decoder =
311312 projectDataManager .getBlazeProjectData ().getArtifactLocationDecoder ();
313+
314+ String workSpaceRootPath = WorkspaceRoot .fromProject (project ).directory ().getAbsolutePath ();
315+
312316 SuccessorsFunction <FastBuildBlazeData > graph = l -> getDependencies (blazeData , l );
313317 Traverser .forGraph (graph )
314318 .breadthFirst (data )
@@ -319,15 +323,24 @@ private ImmutableSet<File> getSourceFilesRecursively(
319323 .map (decoder ::decode )
320324 .filter (f -> f .getName ().endsWith (".java" ) || f .getName ().endsWith (".scala" ))
321325 .forEach (sourceFiles ::add );
326+ addBuildFile (sourceFiles , workSpaceRootPath , d .buildFilePath ());
322327 } else if (d .protoInfo ().isPresent ()) {
323328 d .protoInfo ().get ().sources ().stream ()
324329 .map (decoder ::decode )
325330 .forEach (sourceFiles ::add );
331+ addBuildFile (sourceFiles , workSpaceRootPath , d .buildFilePath ());
326332 }
327333 });
328334 return ImmutableSet .copyOf (sourceFiles );
329335 }
330336
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+
331344 private static ImmutableSet <FastBuildBlazeData > getDependencies (
332345 Map <Label , FastBuildBlazeData > map , FastBuildBlazeData labelData ) {
333346 return labelData .dependencies ().stream ()
0 commit comments