mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
Build output view: display aggregated errors/warnings information
This commit is contained in:
@@ -39,6 +39,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.ui.treeStructure.SimpleNode;
|
||||
import com.intellij.ui.treeStructure.SimpleTreeBuilder;
|
||||
import com.intellij.ui.treeStructure.SimpleTreeStructure;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
@@ -119,7 +120,7 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
}
|
||||
}
|
||||
};
|
||||
final ExecutionNode rootNode = new ExecutionNode(myProject);
|
||||
final ExecutionNode rootNode = new ExecutionNode(myProject, null);
|
||||
rootNode.setAutoExpandNode(true);
|
||||
final ListTreeTableModelOnColumns model = new ListTreeTableModelOnColumns(new DefaultMutableTreeNode(rootNode), COLUMNS);
|
||||
|
||||
@@ -325,7 +326,16 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
if (event instanceof StartEvent || event instanceof MessageEvent) {
|
||||
ExecutionNode rootElement = getRootElement();
|
||||
if (currentNode == null) {
|
||||
currentNode = event instanceof StartBuildEvent ? rootElement : new ExecutionNode(myProject);
|
||||
if (event instanceof StartBuildEvent) {
|
||||
currentNode = rootElement;
|
||||
}
|
||||
else {
|
||||
if (event instanceof MessageEvent) {
|
||||
MessageEvent messageEvent = (MessageEvent)event;
|
||||
parentNode = createMessageParentNodes(messageEvent, parentNode);
|
||||
}
|
||||
currentNode = new ExecutionNode(myProject, parentNode);
|
||||
}
|
||||
currentNode.setAutoExpandNode(currentNode == rootElement || parentNode == rootElement);
|
||||
nodesMap.put(event.getId(), currentNode);
|
||||
}
|
||||
@@ -334,15 +344,6 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof MessageEvent) {
|
||||
MessageEvent messageEvent = (MessageEvent)event;
|
||||
currentNode.setStartTime(messageEvent.getEventTime());
|
||||
currentNode.setEndTime(messageEvent.getEventTime());
|
||||
currentNode.setNavigatable(messageEvent.getNavigatable(myProject));
|
||||
final MessageEventResult messageEventResult = messageEvent.getResult();
|
||||
currentNode.setResult(messageEventResult);
|
||||
parentNode = createMessageParentNodes(messageEvent, parentNode);
|
||||
}
|
||||
if (parentNode != null) {
|
||||
parentNode.add(currentNode);
|
||||
}
|
||||
@@ -353,11 +354,19 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
currentNode.setAutoExpandNode(true);
|
||||
myProgressAnimator.startMovie();
|
||||
}
|
||||
else if (event instanceof MessageEvent) {
|
||||
MessageEvent messageEvent = (MessageEvent)event;
|
||||
currentNode.setStartTime(messageEvent.getEventTime());
|
||||
currentNode.setEndTime(messageEvent.getEventTime());
|
||||
currentNode.setNavigatable(messageEvent.getNavigatable(myProject));
|
||||
final MessageEventResult messageEventResult = messageEvent.getResult();
|
||||
currentNode.setResult(messageEventResult);
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentNode = nodesMap.get(event.getId());
|
||||
if (currentNode == null && event instanceof ProgressBuildEvent) {
|
||||
currentNode = new ExecutionNode(myProject);
|
||||
currentNode = new ExecutionNode(myProject, parentNode);
|
||||
nodesMap.put(event.getId(), currentNode);
|
||||
if (parentNode != null) {
|
||||
parentNode.add(currentNode);
|
||||
@@ -405,7 +414,7 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
JTree tree = myBuilder.getTree();
|
||||
if (tree != null && !tree.isRootVisible()) {
|
||||
ExecutionNode rootElement = getRootElement();
|
||||
ExecutionNode resultNode = new ExecutionNode(myProject);
|
||||
ExecutionNode resultNode = new ExecutionNode(myProject, rootElement);
|
||||
resultNode.setName(StringUtil.toTitleCase(rootElement.getName()));
|
||||
resultNode.setHint(rootElement.getHint());
|
||||
resultNode.setEndTime(rootElement.getEndTime());
|
||||
@@ -445,12 +454,13 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
getOrCreateMessagesNode(messageEvent, groupNodeId, parentNode, null, group, true, null, null, nodesMap, myProject);
|
||||
|
||||
EventResult groupNodeResult = messagesGroupNode.getResult();
|
||||
final MessageEvent.Kind eventKind = messageEvent.getKind();
|
||||
if (!(groupNodeResult instanceof MessageEventResult) ||
|
||||
((MessageEventResult)groupNodeResult).getKind().compareTo(messageEvent.getKind()) > 0) {
|
||||
((MessageEventResult)groupNodeResult).getKind().compareTo(eventKind) > 0) {
|
||||
messagesGroupNode.setResult(new MessageEventResult() {
|
||||
@Override
|
||||
public MessageEvent.Kind getKind() {
|
||||
return messageEvent.getKind();
|
||||
return eventKind;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -499,6 +509,13 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
parentNode = messagesGroupNode;
|
||||
}
|
||||
|
||||
if (eventKind == MessageEvent.Kind.ERROR || eventKind == MessageEvent.Kind.WARNING) {
|
||||
SimpleNode p = parentNode;
|
||||
do {
|
||||
((ExecutionNode)p).reportChildMessageKind(eventKind);
|
||||
}
|
||||
while ((p = p.getParent()) instanceof ExecutionNode);
|
||||
}
|
||||
return parentNode;
|
||||
}
|
||||
|
||||
@@ -515,7 +532,7 @@ public class BuildTreeConsoleView implements ConsoleView, DataProvider, BuildCon
|
||||
Project project) {
|
||||
ExecutionNode node = nodesMap.get(nodeId);
|
||||
if (node == null) {
|
||||
node = new ExecutionNode(project);
|
||||
node = new ExecutionNode(project, parentNode);
|
||||
node.setName(nodeName);
|
||||
node.setTitle(nodeTitle);
|
||||
if (autoExpandNode) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -44,11 +45,11 @@ public class ExecutionNode extends CachingSimpleNode {
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
@Nullable
|
||||
private String title;
|
||||
private String myTitle;
|
||||
@Nullable
|
||||
private String tooltip;
|
||||
private String myTooltip;
|
||||
@Nullable
|
||||
private String hint;
|
||||
private String myHint;
|
||||
@Nullable
|
||||
private EventResult myResult;
|
||||
private boolean myAutoExpandNode;
|
||||
@@ -56,9 +57,11 @@ public class ExecutionNode extends CachingSimpleNode {
|
||||
private Navigatable myNavigatable;
|
||||
@Nullable
|
||||
private NullableLazyValue<Icon> myPreferredIconValue;
|
||||
private final AtomicInteger myErrors = new AtomicInteger();
|
||||
private final AtomicInteger myWarnings = new AtomicInteger();
|
||||
|
||||
public ExecutionNode(Project aProject) {
|
||||
super(aProject, null);
|
||||
public ExecutionNode(Project aProject, ExecutionNode parentNode) {
|
||||
super(aProject, parentNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,17 +74,19 @@ public class ExecutionNode extends CachingSimpleNode {
|
||||
setIcon(getCurrentIcon());
|
||||
presentation.setPresentableText(myName);
|
||||
presentation.setIcon(getIcon());
|
||||
if (title != null) {
|
||||
presentation.addText(title + ": ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
if (myTitle != null) {
|
||||
presentation.addText(myTitle + ": ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
if(title != null || hint != null) {
|
||||
|
||||
String hint = getCurrentHint();
|
||||
if (myTitle != null || hint != null) {
|
||||
presentation.addText(myName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
if (hint != null) {
|
||||
presentation.addText(" " + hint, SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
if (tooltip != null) {
|
||||
presentation.setTooltip(tooltip);
|
||||
if (myTooltip != null) {
|
||||
presentation.setTooltip(myTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,29 +101,29 @@ public class ExecutionNode extends CachingSimpleNode {
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
public void setTitle(@Nullable String title) {
|
||||
this.title = title;
|
||||
myTitle = title;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTooltip() {
|
||||
return tooltip;
|
||||
return myTooltip;
|
||||
}
|
||||
|
||||
public void setTooltip(@Nullable String tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
myTooltip = tooltip;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHint() {
|
||||
return hint;
|
||||
return myHint;
|
||||
}
|
||||
|
||||
public void setHint(@Nullable String hint) {
|
||||
this.hint = hint;
|
||||
myHint = hint;
|
||||
}
|
||||
|
||||
public void add(ExecutionNode node) {
|
||||
@@ -228,6 +233,40 @@ public class ExecutionNode extends CachingSimpleNode {
|
||||
};
|
||||
}
|
||||
|
||||
public void reportChildMessageKind(MessageEvent.Kind kind) {
|
||||
if (kind == MessageEvent.Kind.ERROR) {
|
||||
myErrors.incrementAndGet();
|
||||
}
|
||||
else if (kind == MessageEvent.Kind.WARNING) {
|
||||
myWarnings.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentHint() {
|
||||
String hint = myHint;
|
||||
int warnings = myWarnings.get();
|
||||
int errors = myErrors.get();
|
||||
if (warnings > 0 || errors > 0) {
|
||||
if (hint == null) {
|
||||
hint = "";
|
||||
}
|
||||
hint += (getParent() == null ? isRunning() ? " " : " with " : " (");
|
||||
if (errors > 0) {
|
||||
hint += (errors + " " + StringUtil.pluralize("error", errors));
|
||||
if (warnings > 0) {
|
||||
hint += ", ";
|
||||
}
|
||||
}
|
||||
if (warnings > 0) {
|
||||
hint += (warnings + " " + StringUtil.pluralize("warning", warnings));
|
||||
}
|
||||
if (getParent() != null) {
|
||||
hint += ")";
|
||||
}
|
||||
}
|
||||
return hint;
|
||||
}
|
||||
|
||||
private Icon getCurrentIcon() {
|
||||
if (myPreferredIconValue != null) {
|
||||
return myPreferredIconValue.getValue();
|
||||
|
||||
Reference in New Issue
Block a user