use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeIdeInterfaceAspectsImpl method getIdeInfo.
private static IdeInfoResult getIdeInfo(Project project, BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, ImmutableSet<LanguageClass> activeLanguages, ShardedTargetList shardedTargets, AspectStrategy aspectStrategy) {
return Scope.push(parentContext, context -> {
context.push(new TimingScope(String.format("Execute%sCommand", Blaze.buildSystemName(project)), EventType.BlazeInvocation));
Set<File> ideInfoFiles = new LinkedHashSet<>();
Function<Integer, String> progressMessage = count -> String.format("Building IDE info files for shard %s of %s...", count, shardedTargets.shardedTargets.size());
Function<List<TargetExpression>, BuildResult> invocation = targets -> {
IdeInfoResult result = getIdeInfoForTargets(project, context, workspaceRoot, projectViewSet, activeLanguages, targets, aspectStrategy);
ideInfoFiles.addAll(result.files);
return result.buildResult;
};
BuildResult result = shardedTargets.runShardedCommand(project, context, progressMessage, invocation);
return new IdeInfoResult(ideInfoFiles, result);
});
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class DirectoryStructure method walkDirectoryStructure.
private static ListenableFuture<PathStructurePair> walkDirectoryStructure(WorkspaceRoot workspaceRoot, Set<WorkspacePath> excludeDirectories, FileOperationProvider fileOperationProvider, ListeningExecutorService executorService, WorkspacePath workspacePath) {
if (excludeDirectories.contains(workspacePath)) {
return Futures.immediateFuture(null);
}
File file = workspaceRoot.fileForPath(workspacePath);
if (!fileOperationProvider.isDirectory(file)) {
return Futures.immediateFuture(null);
}
ListenableFuture<File[]> childrenFuture = executorService.submit(() -> fileOperationProvider.listFiles(file));
return Futures.transformAsync(childrenFuture, children -> {
if (children == null) {
return Futures.immediateFuture(null);
}
List<ListenableFuture<PathStructurePair>> futures = Lists.newArrayListWithExpectedSize(children.length);
for (File child : children) {
WorkspacePath childWorkspacePath;
try {
childWorkspacePath = workspaceRoot.workspacePathFor(child);
} catch (IllegalArgumentException e) {
// stop at directories with unhandled characters.
continue;
}
futures.add(walkDirectoryStructure(workspaceRoot, excludeDirectories, fileOperationProvider, executorService, childWorkspacePath));
}
return Futures.transform(Futures.allAsList(futures), (Function<List<PathStructurePair>, PathStructurePair>) pairs -> {
Builder<WorkspacePath, DirectoryStructure> result = ImmutableMap.builder();
for (PathStructurePair pair : pairs) {
if (pair != null) {
result.put(pair.path, pair.directoryStructure);
}
}
return new PathStructurePair(workspacePath, new DirectoryStructure(result.build()));
}, executorService);
}, executorService);
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeIntegrationTestCase method setUp.
@Before
public final void setUp() throws Exception {
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(LightCodeInsightFixtureTestCase.JAVA_8);
final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
testFixture = factory.createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
testFixture.setUp();
fileSystem = new TestFileSystem(getProject(), testFixture.getTempDirFixture());
runWriteAction(() -> {
ProjectJdkTable.getInstance().addJdk(IdeaTestUtil.getMockJdk18());
VirtualFile workspaceRootVirtualFile = fileSystem.createDirectory("workspace");
workspaceRoot = new WorkspaceRoot(new File(workspaceRootVirtualFile.getPath()));
projectDataDirectory = fileSystem.createDirectory("project-data-dir");
workspace = new WorkspaceFileSystem(workspaceRoot, fileSystem);
});
BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(new BlazeImportSettings(workspaceRoot.toString(), "test-project", projectDataDirectory.getPath(), workspaceRoot.fileForPath(new WorkspacePath("project-view-file")).getPath(), buildSystem()));
registerApplicationService(FileOperationProvider.class, new TestFileSystem.MockFileOperationProvider());
registerApplicationService(InputStreamProvider.class, file -> {
VirtualFile vf = fileSystem.findFile(file.getPath());
if (vf == null) {
throw new FileNotFoundException();
}
return vf.getInputStream();
});
registerApplicationService(VirtualFileSystemProvider.class, new TestFileSystem.TempVirtualFileSystemProvider());
String requiredPlugins = System.getProperty("idea.required.plugins.id");
if (requiredPlugins != null) {
VerifyRequiredPluginsEnabled.runCheck(requiredPlugins.split(","));
}
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeCidrLauncher method createProcess.
@Override
public ProcessHandler createProcess(CommandLineState state) throws ExecutionException {
ImmutableList<String> testHandlerFlags = ImmutableList.of();
BlazeTestUiSession testUiSession = useTestUi() ? TestUiSessionProvider.getInstance(project).getTestUiSession(configuration.getTarget()) : null;
if (testUiSession != null) {
testHandlerFlags = testUiSession.getBlazeFlags();
}
ProjectViewSet projectViewSet = Preconditions.checkNotNull(ProjectViewManager.getInstance(project).getProjectViewSet());
List<String> fixedBlazeFlags = getFixedBlazeFlags();
BlazeCommand.Builder command = BlazeCommand.builder(Blaze.getBuildSystemProvider(project).getBinaryPath(), handlerState.getCommandState().getCommand()).addTargets(configuration.getTarget()).addBlazeFlags(BlazeFlags.blazeFlags(project, projectViewSet, handlerState.getCommandState().getCommand(), BlazeInvocationContext.NonSync)).addBlazeFlags(testHandlerFlags).addBlazeFlags(fixedBlazeFlags).addExeFlags(handlerState.getExeFlagsState().getExpandedFlags());
state.setConsoleBuilder(createConsoleBuilder(testUiSession));
state.addConsoleFilters(getConsoleFilters().toArray(new Filter[0]));
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
return new ScopedBlazeProcessHandler(project, command.build(), workspaceRoot, new ScopedBlazeProcessHandler.ScopedProcessHandlerDelegate() {
@Override
public void onBlazeContextStart(BlazeContext context) {
context.push(new IssuesScope(project, BlazeUserSettings.getInstance().getShowProblemsViewForRunAction()));
}
@Override
public ImmutableList<ProcessListener> createProcessListeners(BlazeContext context) {
LineProcessingOutputStream outputStream = LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context));
return ImmutableList.of(new LineProcessingProcessAdapter(outputStream));
}
});
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeCoverageEngine method createCoverageViewExtension.
@Nullable
@Override
public CoverageViewExtension createCoverageViewExtension(Project project, CoverageSuitesBundle suites, StateBean stateBean) {
WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(project);
if (root == null) {
return null;
}
Set<File> topLevelDirectories = getTopLevelDirectories(suites);
if (topLevelDirectories.isEmpty()) {
return null;
}
CoverageAnnotator annotator = getCoverageAnnotator(project);
return new DirectoryCoverageViewExtension(project, annotator, suites, stateBean) {
private List<AbstractTreeNode> topLevelNodes;
@Override
public AbstractTreeNode createRootNode() {
if (topLevelDirectories.size() == 1) {
File file = topLevelDirectories.iterator().next();
return new CoverageListRootNode(project, resolveFile(project, file), suites, stateBean);
}
return new CoverageListRootNode(project, resolveFile(project, root.directory()), suites, stateBean) {
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
return getRootChildren(this);
}
};
}
@Override
public List<AbstractTreeNode> getChildrenNodes(AbstractTreeNode node) {
if (node instanceof CoverageListRootNode && topLevelDirectories.size() != 1) {
return getRootChildren((CoverageListRootNode) node);
}
return super.getChildrenNodes(node).stream().filter(treeNode -> !isLeaf(treeNode) || getPercentage(0, treeNode) != null).collect(Collectors.toList());
}
private List<AbstractTreeNode> getRootChildren(CoverageListRootNode root) {
if (topLevelNodes == null) {
topLevelNodes = ReadAction.compute(() -> getTopLevelNodes(project, suites, stateBean));
for (AbstractTreeNode node : topLevelNodes) {
node.setParent(root);
}
}
return topLevelNodes;
}
};
}
Aggregations