Search in sources :

Example 21 with IssueOutput

use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.

the class BlazeIssueParserTest method testParseGenericError.

@Test
public void testParseGenericError() {
    BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
    String msg = "Bad target pattern 'USE_CANARY_BLAZE=1': package names may contain only " + "A-Z, a-z, 0-9, '/', '-', '.', ' ', '$', '(', ')' and '_'.";
    IssueOutput issue = blazeIssueParser.parseIssue("ERROR: " + msg);
    assertThat(issue).isNotNull();
    assertThat(issue.getMessage()).isEqualTo(msg);
    assertThat(issue.getCategory()).isEqualTo(IssueOutput.Category.ERROR);
}
Also used : IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Test(org.junit.Test)

Example 22 with IssueOutput

use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.

the class BlazeIssueParserTest method testPackageProjectViewParser.

@Test
public void testPackageProjectViewParser() {
    BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
    IssueOutput issue = blazeIssueParser.parseIssue("no such package 'package/path': BUILD file not found on package path");
    assertThat(issue).isNotNull();
    assertThat(issue.getFile().getPath()).isEqualTo(".blazeproject");
    assertThat(issue.getCategory()).isEqualTo(IssueOutput.Category.ERROR);
}
Also used : IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Test(org.junit.Test)

Example 23 with IssueOutput

use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.

the class BlazeIssueParserTest method testLabelProjectViewParser.

@Test
public void testLabelProjectViewParser() {
    BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
    IssueOutput issue = blazeIssueParser.parseIssue("no such target '//package/path:hello4': " + "target 'hello4' not declared in package 'package/path' " + "defined by /path/to/root/package/path/BUILD");
    assertThat(issue).isNotNull();
    assertThat(issue.getFile().getPath()).isEqualTo(".blazeproject");
    assertThat(issue.getCategory()).isEqualTo(IssueOutput.Category.ERROR);
}
Also used : IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Test(org.junit.Test)

Example 24 with IssueOutput

use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.

the class IssueOutputFilter method getHyperlinkInfo.

@Nullable
private static HyperlinkInfo getHyperlinkInfo(IssueOutput issue) {
    Navigatable navigatable = issue.getNavigatable();
    if (navigatable != null) {
        return project -> navigatable.navigate(true);
    }
    VirtualFile vf = resolveVirtualFile(issue.getFile());
    return vf != null ? project -> new OpenFileDescriptor(project, vf, issue.getLine() - 1, issue.getColumn() - 1).navigate(true) : null;
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindow(com.intellij.openapi.wm.ToolWindow) Filter(com.intellij.execution.filters.Filter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TextRange(com.intellij.openapi.util.TextRange) BlazeConsoleToolWindowFactory(com.google.idea.blaze.base.console.BlazeConsoleToolWindowFactory) VfsUtils(com.google.idea.blaze.base.io.VfsUtils) File(java.io.File) ArrayList(java.util.ArrayList) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Parser(com.google.idea.blaze.base.issueparser.BlazeIssueParser.Parser) BlazeConsoleView(com.google.idea.blaze.base.console.BlazeConsoleView) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) Project(com.intellij.openapi.project.Project) BlazeInvocationContext(com.google.idea.blaze.base.command.BlazeInvocationContext) Navigatable(com.intellij.pom.Navigatable) Logger(com.intellij.openapi.diagnostic.Logger) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) BlazeProblemsView(com.google.idea.blaze.base.ui.problems.BlazeProblemsView) Nullable(javax.annotation.Nullable) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Navigatable(com.intellij.pom.Navigatable) Nullable(javax.annotation.Nullable)

Example 25 with IssueOutput

use of com.google.idea.blaze.base.scope.output.IssueOutput in project intellij by bazelbuild.

the class IssueOutputFilter method applyFilter.

@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
    IssueOutput issue = issueParser.parseIssue(line);
    if (issue == null) {
        return null;
    }
    logger.warn(issue.toString());
    List<ResultItem> links = new ArrayList<>();
    int offset = entireLength - line.length();
    if (linkToBlazeConsole) {
        ResultItem dummyResult = dummyResult(offset);
        BlazeProblemsView.getInstance(project).addMessage(issue, openConsoleToHyperlink(dummyResult.getHyperlinkInfo(), offset));
        links.add(dummyResult);
    } else {
        BlazeProblemsView.getInstance(project).addMessage(issue, null);
    }
    ResultItem hyperlink = hyperlinkItem(issue, offset);
    if (hyperlink != null) {
        links.add(hyperlink);
    }
    return !links.isEmpty() ? new Result(links) : null;
}
Also used : ArrayList(java.util.ArrayList) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Nullable(javax.annotation.Nullable)

Aggregations

IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)27 Test (org.junit.Test)19 Nullable (javax.annotation.Nullable)4 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)3 File (java.io.File)3 List (java.util.List)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)2 ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)2 ProjectViewParser (com.google.idea.blaze.base.projectview.parser.ProjectViewParser)2 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)2 Scope (com.google.idea.blaze.base.scope.Scope)2 BuildSystem (com.google.idea.blaze.base.settings.Blaze.BuildSystem)2 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)2 BlazeValidationError (com.google.idea.blaze.base.ui.BlazeValidationError)2 BlazeValidationResult (com.google.idea.blaze.base.ui.BlazeValidationResult)2 UiUtil (com.google.idea.blaze.base.ui.UiUtil)2 ProjectDataDirectoryValidator (com.google.idea.blaze.base.wizard2.ProjectDataDirectoryValidator)2 Disposable (com.intellij.openapi.Disposable)2 Logger (com.intellij.openapi.diagnostic.Logger)2