use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class DuplicateSourceDetector method reportDuplicates.
public void reportDuplicates(BlazeContext context) {
List<Duplicate> duplicates = Lists.newArrayList();
for (ArtifactLocation key : artifacts.keySet()) {
Collection<TargetKey> labels = artifacts.get(key);
if (labels.size() > 1) {
// Workaround for aspect bug. Can be removed after the next blaze release, as of May 27 2016
Set<TargetKey> labelSet = Sets.newHashSet(labels);
if (labelSet.size() > 1) {
duplicates.add(new Duplicate(key, labelSet));
}
}
}
if (duplicates.isEmpty()) {
return;
}
duplicates.sort(Comparator.comparing(lhs -> lhs.artifactLocation.getRelativePath()));
context.output(new PerformanceWarning("Duplicate sources detected:"));
for (Duplicate duplicate : duplicates) {
ArtifactLocation artifactLocation = duplicate.artifactLocation;
context.output(new PerformanceWarning(" Source: " + artifactLocation.getRelativePath()));
context.output(new PerformanceWarning(" Consumed by rules:"));
for (TargetKey targetKey : duplicate.targets) {
context.output(new PerformanceWarning(" " + targetKey.label));
}
// Newline
context.output(new PerformanceWarning(""));
}
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class SourceDirectoryCalculator method calculateContentEntries.
public ImmutableList<BlazeContentEntry> calculateContentEntries(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ArtifactLocationDecoder artifactLocationDecoder, ImportRoots importRoots, Collection<SourceArtifact> sources, Map<TargetKey, ArtifactLocation> javaPackageManifests) {
ManifestFilePackageReader manifestFilePackageReader = Scope.push(context, (childContext) -> {
childContext.push(new TimingScope("ReadPackageManifests", EventType.Other));
Map<TargetKey, Map<ArtifactLocation, String>> manifestMap = PackageManifestReader.getInstance().readPackageManifestFiles(project, childContext, artifactLocationDecoder, javaPackageManifests, packageReaderExecutorService);
return new ManifestFilePackageReader(manifestMap);
});
final List<JavaPackageReader> javaPackageReaders = Lists.newArrayList(manifestFilePackageReader, JavaSourcePackageReader.getInstance(), generatedFileJavaPackageReader);
Collection<SourceArtifact> nonGeneratedSources = filterGeneratedArtifacts(sources);
// Sort artifacts and excludes into their respective workspace paths
Multimap<WorkspacePath, SourceArtifact> sourcesUnderDirectoryRoot = sortArtifactLocationsByRootDirectory(context, importRoots, nonGeneratedSources);
List<BlazeContentEntry> result = Lists.newArrayList();
Scope.push(context, (childContext) -> {
childContext.push(new TimingScope("CalculateSourceDirectories", EventType.Other));
for (WorkspacePath workspacePath : importRoots.rootDirectories()) {
File contentRoot = workspaceRoot.fileForPath(workspacePath);
ImmutableList<BlazeSourceDirectory> sourceDirectories = calculateSourceDirectoriesForContentRoot(context, workspaceRoot, artifactLocationDecoder, workspacePath, sourcesUnderDirectoryRoot.get(workspacePath), javaPackageReaders);
if (!sourceDirectories.isEmpty()) {
result.add(new BlazeContentEntry(contentRoot, sourceDirectories));
}
}
result.sort(Comparator.comparing(lhs -> lhs.contentRoot));
});
return ImmutableList.copyOf(result);
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeJavaRunProfileState method startProcess.
@Override
protected ProcessHandler startProcess() throws ExecutionException {
Project project = configuration.getProject();
BlazeCommand.Builder blazeCommand;
BlazeTestUiSession testUiSession = useTestUi() ? TestUiSessionProvider.getInstance(project).getTestUiSession(configuration.getTarget()) : null;
if (testUiSession != null) {
blazeCommand = getBlazeCommandBuilder(project, configuration, testUiSession.getBlazeFlags(), executorType);
setConsoleBuilder(new TextConsoleBuilderImpl(project) {
@Override
protected ConsoleView createConsole() {
return SmRunnerUtils.getConsoleView(project, configuration, getEnvironment().getExecutor(), testUiSession);
}
});
} else {
blazeCommand = getBlazeCommandBuilder(project, configuration, ImmutableList.of(), executorType);
}
addConsoleFilters(new BlazeTargetFilter(project, true), new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.NonSync, false));
List<String> command = HotSwapUtils.canHotSwap(getEnvironment()) ? getBashCommandsToRunScript(blazeCommand) : blazeCommand.build().toList();
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
return new ScopedBlazeProcessHandler(project, command, workspaceRoot, new ScopedBlazeProcessHandler.ScopedProcessHandlerDelegate() {
@Override
public void onBlazeContextStart(BlazeContext context) {
context.push(new IssuesScope(project, BlazeUserSettings.getInstance().getShowProblemsViewForRunAction())).push(new IdeaLogScope());
}
@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.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method initTest.
@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(Container applicationServices, Container projectServices) {
applicationServices.register(ExperimentService.class, new MockExperimentService());
BlazeExecutor blazeExecutor = new MockBlazeExecutor();
applicationServices.register(BlazeExecutor.class, blazeExecutor);
projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
// will silently fall back to FilePathJavaPackageReader
applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {
@Nullable
@Override
public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
return null;
}
});
applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
applicationServices.register(PrefetchService.class, new MockPrefetchService());
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
augmenters = registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
}
use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.
the class BlazeKotlinSyncPluginTest method initTest.
@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
super.initTest(applicationServices, projectServices);
ExtensionPointImpl<BuildSystemProvider> buildSystems = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
buildSystems.registerExtension(new BazelBuildSystemProvider());
ExtensionPointImpl<BlazeSyncPlugin> syncPlugins = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
syncPlugins.registerExtension(new BlazeJavaSyncPlugin());
syncPlugins.registerExtension(new BlazeKotlinSyncPlugin());
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
}
Aggregations