use of com.google.idea.blaze.base.sync.BuildTargetFinder in project intellij by bazelbuild.
the class PartialSyncAction method getTargets.
private static List<TargetExpression> getTargets(Project project, @Nullable VirtualFile virtualFile) {
if (virtualFile == null) {
return ImmutableList.of();
}
List<TargetExpression> targets = Lists.newArrayList();
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SourceToTargetMap.getInstance(project);
if (!virtualFile.isDirectory()) {
targets.addAll(SourceToTargetMap.getInstance(project).getTargetsToBuildForSourceFile(new File(virtualFile.getPath())));
}
if (targets.isEmpty()) {
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet != null) {
BuildSystem buildSystem = Blaze.getBuildSystem(project);
ImportRoots importRoots = ImportRoots.builder(workspaceRoot, buildSystem).add(projectViewSet).build();
BuildTargetFinder buildTargetFinder = new BuildTargetFinder(project, workspaceRoot, importRoots);
TargetExpression targetExpression = buildTargetFinder.findTargetForFile(new File(virtualFile.getPath()));
if (targetExpression != null) {
targets.add(targetExpression);
}
}
}
return targets;
}
Aggregations