use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class AddSourceToProjectHelper method getContext.
/**
* Returns the location context related to a source file to be added to the project.
*/
@Nullable
static LocationContext getContext(Project project, File file) {
BlazeProjectData syncData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (syncData == null) {
return null;
}
WorkspacePath workspacePath = getWorkspacePath(project, file);
if (workspacePath == null || isBuildSystemOutputArtifact(project, workspacePath)) {
return null;
}
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet == null) {
return null;
}
WorkspacePath parent = workspacePath.getParent();
if (parent == null) {
return null;
}
WorkspacePath blazePackage = findBlazePackagePath(project, parent);
return blazePackage != null ? new LocationContext(project, syncData, projectViewSet, file, workspacePath, blazePackage) : null;
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class NewBlazePackageAction method isUnderProjectViewDirectory.
private static boolean isUnderProjectViewDirectory(WorkspaceRoot workspaceRoot, ImportRoots importRoots, PsiDirectory directory) {
VirtualFile virtualFile = directory.getVirtualFile();
// Ignore jars, etc. and their contents, which are in an ArchiveFileSystem.
if (!(virtualFile.isInLocalFileSystem())) {
return false;
}
if (!workspaceRoot.isInWorkspace(virtualFile)) {
return false;
}
WorkspacePath workspacePath = workspaceRoot.workspacePathFor(virtualFile);
return WorkspacePathUtil.isUnderAnyWorkspacePath(importRoots.rootDirectories(), workspacePath);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class AllInPackageBlazeConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
PsiDirectory dir = getTestDirectory(context);
if (dir == null) {
return false;
}
WorkspaceRoot root = WorkspaceRoot.fromProject(context.getProject());
WorkspacePath packagePath = getWorkspaceRelativeDirectoryPath(root, dir);
if (packagePath == null) {
return false;
}
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
return Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.TEST) && Objects.equals(configuration.getTarget(), TargetExpression.allFromPackageRecursive(packagePath));
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewVerifier method verifyIncludedPackagesAreNotExcluded.
private static boolean verifyIncludedPackagesAreNotExcluded(BlazeContext context, ProjectViewSet projectViewSet) {
boolean ok = true;
List<WorkspacePath> includedDirectories = projectViewSet.listItems(DirectorySection.KEY).stream().filter(entry -> entry.included).map(entry -> entry.directory).collect(toList());
for (WorkspacePath includedDirectory : includedDirectories) {
for (ProjectViewSet.ProjectViewFile projectViewFile : projectViewSet.getProjectViewFiles()) {
List<DirectoryEntry> directoryEntries = Lists.newArrayList();
for (ListSection<DirectoryEntry> section : projectViewFile.projectView.getSectionsOfType(DirectorySection.KEY)) {
directoryEntries.addAll(section.items());
}
for (DirectoryEntry entry : directoryEntries) {
if (entry.included) {
continue;
}
WorkspacePath excludedDirectory = entry.directory;
if (FileUtil.isAncestor(excludedDirectory.relativePath(), includedDirectory.relativePath(), false)) {
IssueOutput.error(String.format("%s is included, but that contradicts %s which was excluded", includedDirectory.toString(), excludedDirectory.toString())).inFile(projectViewFile.projectViewFile).submit(context);
ok = false;
}
}
}
}
return ok;
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewParserIntegrationTest method parse.
private String parse(String... lines) {
PsiFile file = workspace.createPsiFile(new WorkspacePath(".blazeproject"), lines);
collectErrors(file);
return treeToString(file);
}
Aggregations