use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeGoBinaryConfigurationProducer method getTargetLabel.
@Nullable
private static TargetInfo getTargetLabel(PsiFile psiFile) {
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(psiFile.getProject()).getBlazeProjectData();
if (projectData == null) {
return null;
}
VirtualFile vf = psiFile.getVirtualFile();
if (vf == null) {
return null;
}
File file = new File(vf.getPath());
return SourceToTargetMap.getInstance(psiFile.getProject()).getRulesForSourceFile(file).stream().map(projectData.targetMap::get).filter(Objects::nonNull).filter(t -> t.kind.languageClass.equals(LanguageClass.GO)).filter(t -> t.kind.ruleType.equals(RuleType.BINARY)).map(TargetIdeInfo::toTargetInfo).findFirst().orElse(null);
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeGoTestLocator method getGoTestTarget.
@Nullable
private static TargetIdeInfo getGoTestTarget(Project project, String path) {
WorkspacePath targetPackage = WorkspacePath.createIfValid(PathUtil.getParentPath(path));
if (targetPackage == null) {
return null;
}
TargetName targetName = TargetName.createIfValid(PathUtil.getFileName(path));
if (targetName == null) {
return null;
}
Label label = Label.create(targetPackage, targetName);
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return null;
}
TargetIdeInfo target = projectData.targetMap.get(TargetKey.forPlainTarget(label));
if (target != null && target.kind.languageClass.equals(LanguageClass.GO) && target.kind.ruleType.equals(RuleType.TEST)) {
return target;
}
return null;
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeGoTestLocator method getGoFiles.
private static List<VirtualFile> getGoFiles(Project project, @Nullable TargetIdeInfo target) {
if (target == null || target.goIdeInfo == null) {
return ImmutableList.of();
}
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
LocalFileSystem lfs = VirtualFileSystemProvider.getInstance().getSystem();
if (projectData == null) {
return ImmutableList.of();
}
return target.goIdeInfo.sources.stream().map(projectData.artifactLocationDecoder::decode).map(lfs::findFileByIoFile).collect(Collectors.toList());
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method computeResolverResult.
private void computeResolverResult(ProjectView projectView, TargetMap targetMap) {
BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).setTargetMap(targetMap).build();
resolverResult = resolver.update(context, workspaceRoot, ProjectViewSet.builder().add(projectView).build(), blazeProjectData, resolverResult);
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class FastBuildIncrementalCompilerImpl method getPathsToCompile.
private Set<File> getPathsToCompile(Label label, TargetMap targetMap, Set<File> modifiedSinceBuild) {
BlazeProjectData projectData = projectDataManager.getBlazeProjectData();
Set<File> sourceFiles = new HashSet<>();
Set<TargetKey> seenTargets = new HashSet<>();
recursivelyAddModifiedJavaSources(projectData.artifactLocationDecoder, targetMap, TargetKey.forPlainTarget(label), seenTargets, sourceFiles, modifiedSinceBuild);
return sourceFiles;
}
Aggregations