use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeSyncTask method run.
@Override
public void run(final ProgressIndicator indicator) {
Scope.root((BlazeContext context) -> {
context.push(new ExperimentScope());
if (showPerformanceWarnings) {
context.push(new PerformanceWarningScope());
}
context.push(new ProgressIndicatorScope(indicator));
if (!syncParams.backgroundSync) {
context.push(new BlazeConsoleScope.Builder(project, indicator).setPopupBehavior(BlazeUserSettings.getInstance().getShowBlazeConsoleOnSync()).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.Sync, true)).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope()).push(new NotificationScope(project, "Sync", "Sync project", "Sync successful", "Sync failed"));
}
context.output(new StatusOutput(String.format("Syncing project: %s...", syncParams)));
syncProject(context);
});
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class PackageLister method expandPackageTargets.
/**
* Expands all-in-package-recursive wildcard targets into all-in-single-package targets by
* traversing the file system, looking for child blaze packages.
*
* <p>Returns null if directory traversal failed or was cancelled.
*/
@Nullable
static Map<TargetExpression, List<TargetExpression>> expandPackageTargets(BuildSystemProvider provider, BlazeContext context, WorkspacePathResolver pathResolver, Collection<WildcardTargetPattern> wildcardPatterns) {
List<ListenableFuture<Entry<TargetExpression, List<TargetExpression>>>> futures = Lists.newArrayList();
for (WildcardTargetPattern pattern : wildcardPatterns) {
if (!pattern.isRecursive() || pattern.toString().startsWith("-")) {
continue;
}
File dir = pathResolver.resolveToFile(pattern.getBasePackage());
if (!FileOperationProvider.getInstance().isDirectory(dir)) {
continue;
}
futures.add(FetchExecutor.EXECUTOR.submit(() -> {
List<TargetExpression> expandedTargets = new ArrayList<>();
traversePackageRecursively(provider, pathResolver, dir, expandedTargets);
return Maps.immutableEntry(pattern.originalPattern, expandedTargets);
}));
}
if (futures.isEmpty()) {
return ImmutableMap.of();
}
FutureResult<List<Entry<TargetExpression, List<TargetExpression>>>> result = FutureUtil.waitForFuture(context, Futures.allAsList(futures)).withProgressMessage("Expanding wildcard target patterns...").timed("ExpandWildcardTargets", EventType.Other).onError("Expanding wildcard target patterns failed").run();
if (!result.success()) {
return null;
}
return result.result().stream().collect(Collectors.toMap(Entry::getKey, Entry::getValue, (x, y) -> x));
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeCppAutoImportHelperTest method resolve.
private void resolve(ProjectView projectView, TargetMap targetMap, OCFile... files) {
BlazeProjectData blazeProjectData = projectDataBuilder().setTargetMap(targetMap).build();
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
BlazeCWorkspace.getInstance(getProject()).update(new BlazeContext(), workspaceRoot, ProjectViewSet.builder().add(projectView).build(), blazeProjectData);
for (OCFile file : files) {
resetFileSymbols(file);
}
FileSymbolTablesCache.getInstance(getProject()).ensurePendingFilesProcessed();
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeGoSyncPluginTest method initTest.
@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
super.initTest(applicationServices, projectServices);
syncPluginEp = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
syncPluginEp.registerExtension(new BlazeGoSyncPlugin());
syncPluginEp.registerExtension(new AlwaysPresentGoSyncPlugin());
// At least one sync plugin providing a default workspace type must be present
syncPluginEp.registerExtension(new BlazeSyncPlugin() {
@Override
public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
return ImmutableList.of(WorkspaceType.JAVA);
}
@Override
public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
return ImmutableSet.of(LanguageClass.JAVA);
}
@Nullable
@Override
public WorkspaceType getDefaultWorkspaceType() {
return WorkspaceType.JAVA;
}
});
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeDartSyncPluginTest method initTest.
@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
super.initTest(applicationServices, projectServices);
ExtensionPointImpl<BlazeSyncPlugin> ep = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
ep.registerExtension(new BlazeDartSyncPlugin());
// add java, because we need at least one WorkspaceType available.
ep.registerExtension(new BlazeSyncPlugin() {
@Override
public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
return ImmutableList.of(WorkspaceType.JAVA);
}
@Override
public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
return ImmutableSet.of(LanguageClass.JAVA);
}
@Override
public WorkspaceType getDefaultWorkspaceType() {
return WorkspaceType.JAVA;
}
});
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
}
Aggregations