Search in sources :

Example 1 with BuckTreeNodeFileError

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError in project buck by facebook.

the class BuckEventsConsumer method buildTargetErrorNode.

private BuckTreeNodeTarget buildTargetErrorNode(String target, List<String> errorMessages) {
    BuckTreeNodeTarget targetNode = new BuckTreeNodeTarget(mCurrentBuildRootElement, target);
    for (String currentError : errorMessages) {
        ErrorExtractor errorExtractor = new ErrorExtractor(currentError);
        ImmutableList<CompilerErrorItem> errorItems = errorExtractor.getErrors();
        BuckTreeNodeFileError currentFileErrorNode = null;
        String currentFilePath = "";
        for (CompilerErrorItem currentErrorItem : errorItems) {
            if (!currentErrorItem.getFilePath().equals(currentFilePath)) {
                if (currentFileErrorNode != null) {
                    // Add to parent
                    targetNode.addFileError(currentFileErrorNode);
                }
                // Create the new node, for the new file
                currentFileErrorNode = new BuckTreeNodeFileError(targetNode, currentErrorItem.getFilePath(), currentErrorItem);
                currentFilePath = currentErrorItem.getFilePath();
            } else {
                currentFileErrorNode.addError(currentErrorItem);
            }
        }
        if (currentFileErrorNode != null) {
            // Add the leftovers
            targetNode.addFileError(currentFileErrorNode);
        }
    }
    return targetNode;
}
Also used : CompilerErrorItem(com.facebook.buck.intellij.ideabuck.ui.utils.CompilerErrorItem) ErrorExtractor(com.facebook.buck.intellij.ideabuck.ui.utils.ErrorExtractor) BuckTreeNodeFileError(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError) BuckTreeNodeTarget(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeTarget)

Example 2 with BuckTreeNodeFileError

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError in project buck by facebook.

the class BuckToolWindowFactory method handleClickOnError.

private void handleClickOnError(BuckTreeNodeDetailError node) {
    TreeNode parentNode = node.getParent();
    if (parentNode instanceof BuckTreeNodeFileError) {
        BuckTreeNodeFileError buckParentNode = (BuckTreeNodeFileError) parentNode;
        DataContext dataContext = DataManager.getInstance().getDataContext();
        Project project = DataKeys.PROJECT.getData(dataContext);
        String relativePath = buckParentNode.getFilePath().replace(project.getBasePath(), "");
        VirtualFile virtualFile = project.getBaseDir().findFileByRelativePath(relativePath);
        OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, virtualFile, node.getLine() - 1, node.getColumn() - 1);
        openFileDescriptor.navigate(true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) TreeNode(javax.swing.tree.TreeNode) BuckTreeNodeFileError(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor)

Example 3 with BuckTreeNodeFileError

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError in project buck by facebook.

the class FileErrorNodeRenderer method render.

@Override
public Component render(Object value) {
    JBLabel result = new JBLabel(((BuckTreeNodeFileError) value).getFilePath(), AllIcons.Ide.Warning_notifications, SwingConstants.HORIZONTAL);
    BuckTreeNodeFileError buckNode = (BuckTreeNodeFileError) value;
    for (int i = 0; i < buckNode.getChildCount(); i++) {
        BuckTreeNodeDetail childNode = (BuckTreeNodeDetail) buckNode.getChildAt(i);
        if (childNode.getType() == BuckTreeNodeDetail.DetailType.ERROR) {
            result.setIcon(AllIcons.Ide.Error);
            result.setForeground(Color.RED);
            break;
        }
    }
    return result;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) BuckTreeNodeFileError(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError) BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Aggregations

BuckTreeNodeFileError (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError)3 BuckTreeNodeDetail (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)1 BuckTreeNodeTarget (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeTarget)1 CompilerErrorItem (com.facebook.buck.intellij.ideabuck.ui.utils.CompilerErrorItem)1 ErrorExtractor (com.facebook.buck.intellij.ideabuck.ui.utils.ErrorExtractor)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JBLabel (com.intellij.ui.components.JBLabel)1 TreeNode (javax.swing.tree.TreeNode)1