Search in sources :

Example 26 with BlazeProjectData

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) RuleType(com.google.idea.blaze.base.model.primitives.RuleType) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) GoFile(com.goide.psi.GoFile) BlazeCommandRunConfigurationType(com.google.idea.blaze.base.run.BlazeCommandRunConfigurationType) VirtualFile(com.intellij.openapi.vfs.VirtualFile) BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) File(java.io.File) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName) Objects(java.util.Objects) GoRunUtil(com.goide.runconfig.GoRunUtil) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) PsiElement(com.intellij.psi.PsiElement) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) PsiFile(com.intellij.psi.PsiFile) BlazeRunConfigurationProducer(com.google.idea.blaze.base.run.producers.BlazeRunConfigurationProducer) Ref(com.intellij.openapi.util.Ref) Nullable(javax.annotation.Nullable) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) GoFile(com.goide.psi.GoFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) Nullable(javax.annotation.Nullable)

Example 27 with BlazeProjectData

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;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Label(com.google.idea.blaze.base.model.primitives.Label) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) TargetName(com.google.idea.blaze.base.model.primitives.TargetName) Nullable(javax.annotation.Nullable)

Example 28 with BlazeProjectData

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());
}
Also used : LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData)

Example 29 with BlazeProjectData

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);
}
Also used : BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData)

Example 30 with BlazeProjectData

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;
}
Also used : BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)82 File (java.io.File)31 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)28 Nullable (javax.annotation.Nullable)24 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)23 Test (org.junit.Test)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)17 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)17 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)15 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)13 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)13 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)13 Project (com.intellij.openapi.project.Project)13 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)11 ImmutableList (com.google.common.collect.ImmutableList)10 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)10 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)8 List (java.util.List)8 BlazeProjectDataManager (com.google.idea.blaze.base.sync.data.BlazeProjectDataManager)7