use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class StandardFileResolver method resolveToFile.
@Nullable
@Override
public VirtualFile resolveToFile(Project project, String fileString) {
File file = new File(fileString);
if (file.isAbsolute()) {
return VirtualFileSystemProvider.getInstance().getSystem().findFileByPath(getCanonicalPathSafe(file));
}
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return null;
}
file = projectData.workspacePathResolver.resolveToFile(fileString);
return VirtualFileSystemProvider.getInstance().getSystem().findFileByPath(file.getPath());
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class TestTargetSourcesHeuristic method matchesSource.
@Override
public boolean matchesSource(Project project, TargetInfo target, @Nullable PsiFile sourcePsiFile, File sourceFile, @Nullable TestSize testSize) {
Optional<ImmutableList<ArtifactLocation>> sources = target.getSources();
if (!sources.isPresent()) {
return false;
}
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return false;
}
ArtifactLocationDecoder decoder = projectData.artifactLocationDecoder;
for (ArtifactLocation src : sources.get()) {
if (decoder.decode(src).equals(sourceFile)) {
return true;
}
}
return false;
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeConfigurationResolver method buildBlazeConfigurationData.
private void buildBlazeConfigurationData(BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, ImmutableMap<TargetKey, CToolchainIdeInfo> toolchainLookupMap, ImmutableMap<File, VirtualFile> headerRoots, ImmutableMap<CToolchainIdeInfo, BlazeCompilerSettings> compilerSettings, CompilerInfoCache compilerInfoCache, ExecutionRootPathResolver executionRootPathResolver, BlazeConfigurationResolverResult oldConfigurationData, BlazeConfigurationResolverResult.Builder builder) {
// Type specification needed to avoid incorrect type inference during command line build.
Scope.push(parentContext, (ScopedOperation) context -> {
context.push(new TimingScope("Build C configuration map", EventType.Other));
ProjectViewTargetImportFilter filter = new ProjectViewTargetImportFilter(project, workspaceRoot, projectViewSet);
ConcurrentMap<TargetKey, BlazeResolveConfigurationData> targetToData = Maps.newConcurrentMap();
List<ListenableFuture<?>> targetToDataFutures = blazeProjectData.targetMap.targets().stream().filter(target -> target.kind.languageClass == LanguageClass.C).filter(target -> target.kind != Kind.CC_TOOLCHAIN).filter(filter::isSourceTarget).filter(BlazeConfigurationResolver::containsCompiledSources).map(target -> submit(() -> {
BlazeResolveConfigurationData data = createResolveConfiguration(target, toolchainLookupMap, headerRoots, compilerSettings, compilerInfoCache, executionRootPathResolver);
if (data != null) {
targetToData.put(target.key, data);
}
return null;
})).collect(Collectors.toList());
try {
Futures.allAsList(targetToDataFutures).get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
context.setCancelled();
return;
} catch (ExecutionException e) {
IssueOutput.error("Could not build C resolve configurations: " + e).submit(context);
logger.error("Could not build C resolve configurations", e);
return;
}
findEquivalenceClasses(context, project, blazeProjectData.workspacePathResolver, targetToData, oldConfigurationData, builder);
});
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeGDBDriverConfiguration method convertToLocalPath.
@Override
public String convertToLocalPath(@Nullable String absolutePath) {
if (absolutePath != null) {
final File file = new File(absolutePath);
final File workspaceDirectory = workspaceRoot.directory();
final String relativePath = gdbPathToWorkspaceRelativePath(workspaceDirectory, file);
File git5SafeFile = null;
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData != null) {
git5SafeFile = blazeProjectData.workspacePathResolver.resolveToFile(relativePath);
}
absolutePath = git5SafeFile == null ? null : git5SafeFile.getPath();
}
return super.convertToLocalPath(absolutePath);
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class JavaSyncTest method testSimpleSyncLogging.
@Test
public void testSimpleSyncLogging() throws Exception {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib");
workspace.createFile(new WorkspacePath("java/com/google/Source.java"), "package com.google;", "public class Source {}");
workspace.createFile(new WorkspacePath("java/com/google/Other.java"), "package com.google;", "public class Other {}");
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("java_library").addSource(sourceRoot("java/com/google/Source.java")).addSource(sourceRoot("java/com/google/Other.java"))).build();
setTargetMap(targetMap);
runBlazeSync(new BlazeSyncParams.Builder("Sync", SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
errorCollector.assertNoIssues();
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
assertThat(blazeProjectData).isNotNull();
assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
assertThat(blazeProjectData.workspaceLanguageSettings.getWorkspaceType()).isEqualTo(WorkspaceType.JAVA);
List<SyncStats> syncStatsList = getSyncStats();
assertThat(syncStatsList).hasSize(1);
SyncStats syncStats = syncStatsList.get(0);
assertThat(syncStats).isNotNull();
assertThat(syncStats.workspaceType()).isEqualTo(WorkspaceType.JAVA);
assertThat(syncStats.blazeProjectTargets()).containsExactly(TargetExpression.fromString("//java/com/google:lib"));
assertThat(syncStats.syncMode()).isEqualTo(SyncMode.INCREMENTAL);
assertThat(syncStats.syncResult()).isEqualTo(SyncResult.SUCCESS);
assertThat(syncStats.startTimeInEpochTime()).isNotEqualTo(0);
assertThat(syncStats.timedEvents()).isNotEmpty();
}
Aggregations