use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile 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.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class AndroidSdkFromProjectView method getAndroidSdkPlatform.
@Nullable
public static AndroidSdkPlatform getAndroidSdkPlatform(BlazeContext context, ProjectViewSet projectViewSet) {
List<Sdk> sdks = BlazeSdkProvider.getInstance().getAllAndroidSdks();
if (sdks.isEmpty()) {
IssueOutput.error("No Android SDK configured. Please use the SDK manager to configure.").navigatable(new Navigatable() {
@Override
public void navigate(boolean b) {
SdkUtil.openSdkManager();
}
@Override
public boolean canNavigate() {
return true;
}
@Override
public boolean canNavigateToSource() {
return false;
}
}).submit(context);
return null;
}
if (projectViewSet == null) {
return null;
}
String androidSdk = projectViewSet.getScalarValue(AndroidSdkPlatformSection.KEY).orElse(null);
Integer androidMinSdk = projectViewSet.getScalarValue(AndroidMinSdkSection.KEY).orElse(null);
if (androidSdk == null) {
ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
IssueOutput.error(("No android_sdk_platform set. Please set to an android platform. " + "Available android_sdk_platforms are: " + getAvailableTargetHashesAsList(sdks))).inFile(projectViewFile != null ? projectViewFile.projectViewFile : null).submit(context);
return null;
}
Sdk sdk = BlazeSdkProvider.getInstance().findSdk(androidSdk);
if (sdk == null) {
ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
IssueOutput.error(("No such android_sdk_platform: '" + androidSdk + "'. " + "Available android_sdk_platforms are: " + getAvailableTargetHashesAsList(sdks) + ". " + "Please change android_sdk_platform or run SDK manager " + "to download missing SDK platforms.")).inFile(projectViewFile != null ? projectViewFile.projectViewFile : null).submit(context);
return null;
}
if (androidMinSdk == null) {
androidMinSdk = getAndroidSdkApiLevel(sdk);
}
return new AndroidSdkPlatform(androidSdk, androidMinSdk);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method updateBuilder.
public void updateBuilder(BlazeNewProjectBuilder builder) {
String projectName = projectNameField.getText().trim();
File projectDataDirectoryFile = new File(projectDataDirField.getText().trim());
if (workspaceOption.allowProjectDataInVcs()) {
projectDataDirectoryFile = new File(projectDataDirectoryFile, BlazeDataStorage.PROJECT_DATA_SUBDIRECTORY);
}
String projectDataDirectory = projectDataDirectoryFile.getPath();
File localProjectViewFile = ProjectViewStorageManager.getLocalProjectViewFileName(builder.getBuildSystem(), new File(projectDataDirectory));
BlazeSelectProjectViewOption selectProjectViewOption = builder.getProjectViewOption();
boolean useSharedProjectView = projectViewUi.getUseSharedProjectView();
// If we're using a shared project view, synthesize a local one that imports the shared one
ProjectViewSet parseResult = projectViewUi.parseProjectView(Lists.newArrayList());
final ProjectView projectView;
final ProjectViewSet projectViewSet;
if (useSharedProjectView && selectProjectViewOption.getSharedProjectView() != null) {
projectView = ProjectView.builder().add(ScalarSection.builder(ImportSection.KEY).set(selectProjectViewOption.getSharedProjectView())).build();
projectViewSet = ProjectViewSet.builder().addAll(parseResult.getProjectViewFiles()).add(localProjectViewFile, projectView).build();
} else {
ProjectViewSet.ProjectViewFile projectViewFile = parseResult.getTopLevelProjectViewFile();
assert projectViewFile != null;
projectView = projectViewFile.projectView;
projectViewSet = parseResult;
}
builder.setProjectView(projectView).setProjectViewFile(localProjectViewFile).setProjectViewSet(projectViewSet).setProjectName(projectName).setProjectDataDirectory(projectDataDirectory);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method modifyInitialProjectView.
private static String modifyInitialProjectView(BuildSystem buildSystem, String initialProjectViewText, WorkspacePathResolver workspacePathResolver) {
BlazeContext context = new BlazeContext();
ProjectViewParser projectViewParser = new ProjectViewParser(context, workspacePathResolver);
projectViewParser.parseProjectView(initialProjectViewText);
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
if (projectViewFile == null) {
return initialProjectViewText;
}
ProjectView projectView = projectViewFile.projectView;
// Sort default value providers to match the section order
List<SectionKey> sectionKeys = Sections.getParsers().stream().map(SectionParser::getSectionKey).collect(toList());
List<ProjectViewDefaultValueProvider> defaultValueProviders = Lists.newArrayList(ProjectViewDefaultValueProvider.EP_NAME.getExtensions());
defaultValueProviders.sort(Comparator.comparingInt(val -> sectionKeys.indexOf(val.getSectionKey())));
for (ProjectViewDefaultValueProvider defaultValueProvider : defaultValueProviders) {
projectView = defaultValueProvider.addProjectViewDefaultValue(buildSystem, projectViewSet, projectView);
}
return ProjectViewParser.projectViewToString(projectView);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class AlwaysPresentGoSyncPlugin method validateProjectView.
@Override
public boolean validateProjectView(@Nullable Project project, BlazeContext context, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings) {
if (workspaceLanguageSettings.isLanguageActive(LanguageClass.GO) && !isGoPluginSupported()) {
IssueOutput.error(String.format("Go is no longer supported by the %s plugin with IntelliJ Community Edition.\n" + "Please install Ultimate Edition and upgrade to the JetBrains Go plugin", Blaze.defaultBuildSystemName())).submit(context);
return false;
}
if (goWorkspaceTypeSupported() || !workspaceLanguageSettings.isWorkspaceType(WorkspaceType.GO)) {
return true;
}
ProjectViewFile topLevelProjectViewFile = projectViewSet.getTopLevelProjectViewFile();
String msg = "Go workspace_type is no longer supported. Please add 'go' to " + "additional_languages instead";
boolean fixable = project != null && topLevelProjectViewFile != null && topLevelProjectViewFile.projectView.getScalarValue(WorkspaceTypeSection.KEY) == WorkspaceType.GO;
msg += fixable ? ". Click here to fix your .blazeproject and resync." : ", then resync.";
IssueOutput.error(msg).navigatable(!fixable ? null : new NavigatableAdapter() {
@Override
public void navigate(boolean requestFocus) {
fixLanguageSupport(project);
}
}).submit(context);
return false;
}
Aggregations