use of com.google.idea.blaze.base.ui.BlazeValidationResult in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method validate.
public BlazeValidationResult validate() {
// Validate project settings fields
String projectName = projectNameField.getText().trim();
if (StringUtil.isEmpty(projectName)) {
return BlazeValidationResult.failure(new BlazeValidationError("Project name is not specified"));
}
String projectDataDirPath = projectDataDirField.getText().trim();
if (StringUtil.isEmpty(projectDataDirPath)) {
return BlazeValidationResult.failure(new BlazeValidationError("Project data directory is not specified"));
}
File projectDataDir = new File(projectDataDirPath);
if (!projectDataDir.isAbsolute()) {
return BlazeValidationResult.failure(new BlazeValidationError("Project data directory is not valid"));
}
for (ProjectDataDirectoryValidator validator : ProjectDataDirectoryValidator.EP_NAME.getExtensions()) {
BlazeValidationResult result = validator.validateDataDirectory(projectDataDir);
if (!result.success) {
return result;
}
}
File workspaceRootDirectory = workspaceRoot.directory();
if (!workspaceOption.allowProjectDataInVcs() && FileUtil.isAncestor(workspaceRootDirectory, projectDataDir, false)) {
return BlazeValidationResult.failure(new BlazeValidationError("Project data directory cannot be inside your workspace. " + "Please choose a directory outside your workspace."));
}
List<IssueOutput> issues = Lists.newArrayList();
ProjectViewSet projectViewSet = projectViewUi.parseProjectView(issues);
BlazeValidationError projectViewParseError = validationErrorFromIssueList(issues);
if (projectViewParseError != null) {
return BlazeValidationResult.failure(projectViewParseError);
}
ProjectViewValidator projectViewValidator = new ProjectViewValidator(workspacePathResolver, projectViewSet);
ProgressManager.getInstance().runProcessWithProgressSynchronously(projectViewValidator, "Validating Project", false, null);
if (!projectViewValidator.success) {
if (!projectViewValidator.errors.isEmpty()) {
return BlazeValidationResult.failure(validationErrorFromIssueList(projectViewValidator.errors));
}
return BlazeValidationResult.failure("Project view validation failed, but we couldn't find an error message. " + "Please report a bug.");
}
List<DirectoryEntry> directories = projectViewSet.listItems(DirectorySection.KEY);
if (directories.isEmpty()) {
String msg = "Add some directories to index in the 'directories' section.";
if (projectViewSet.listItems(TargetSection.KEY).isEmpty()) {
msg += "\nTargets are also generally required to resolve sources.";
}
return BlazeValidationResult.failure(msg);
}
return BlazeValidationResult.success();
}
Aggregations