use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.
the class ErrorCollector method assertIssues.
public void assertIssues(String... requiredMessages) {
List<String> messages = Lists.newArrayList();
for (IssueOutput issue : issues) {
messages.add(issue.getMessage());
}
assertThat(messages).containsExactly((Object[]) requiredMessages);
}
use of com.google.idea.blaze.base.scope.output.IssueOutput 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();
}
use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method validationErrorFromIssueList.
@Nullable
private static BlazeValidationError validationErrorFromIssueList(List<IssueOutput> issues) {
List<IssueOutput> errors = issues.stream().filter(issue -> issue.getCategory() == IssueOutput.Category.ERROR).collect(toList());
if (!errors.isEmpty()) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("The following issues were found:\n\n");
for (IssueOutput issue : errors) {
errorMessage.append(issue.getMessage());
errorMessage.append('\n');
}
return new BlazeValidationError(errorMessage.toString());
}
return null;
}
use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.
the class BlazeProblemsView method addMessage.
public void addMessage(IssueOutput issue, @Nullable Navigatable openInConsole) {
if (!problems.add(issue.toString())) {
return;
}
int count = problemCount.incrementAndGet();
if (count > MAX_ISSUES) {
return;
}
if (count == MAX_ISSUES) {
issue = IssueOutput.warn("Too many problems found. Only showing the first " + MAX_ISSUES).build();
}
VirtualFile file = issue.getFile() != null ? resolveVirtualFile(issue.getFile()) : null;
Navigatable navigatable = issue.getNavigatable();
if (navigatable == null && file != null) {
navigatable = new OpenFileDescriptor(project, file, issue.getLine() - 1, issue.getColumn() - 1);
}
IssueOutput.Category category = issue.getCategory();
int type = translateCategory(category);
String[] text = convertMessage(issue);
String groupName = file != null ? file.getPresentableUrl() : category.name();
addMessage(type, text, groupName, file, navigatable, openInConsole, getExportTextPrefix(issue), getRenderTextPrefix(issue));
if (focusProblemsViewOnIssue && !didFocusProblemsView.get()) {
didFocusProblemsView.set(true);
focusProblemsView();
}
}
use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.
the class PyIssueParserProviderTest method testParsePyTypeError.
@Test
public void testParsePyTypeError() {
BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
IssueOutput issue = blazeIssueParser.parseIssue("File \"dataset.py\", line 109, in Dataset: " + "Name 'function' is not defined [name-error]");
assertThat(issue).isNotNull();
assertThat(issue.getCategory()).isEqualTo(Category.ERROR);
assertThat(issue.getNavigatable()).isNotNull();
assertThat(issue.getConsoleHyperlinkRange()).isEqualTo(TextRange.create("File \"".length(), "File \"dataset.py\", line 109".length()));
}
Aggregations