In preparation of annotation-enforced @Nullable Map.get() etc.
Change-Id: I81385aba7007baf8ad94fc1519689621f1945493
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/58880
Reviewed-by: Hudson CI
package org.eclipse.tracecompass.internal.analysis.graph.ui.criticalpath.view;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
if (!fHostEntries.containsKey(host)) {
fHostEntries.put(host, new CriticalPathEntry(host, fTrace, getStartTime(), getEndTime(), owner));
}
- parent = fHostEntries.get(host);
+ parent = checkNotNull(fHostEntries.get(host));
CriticalPathEntry entry = new CriticalPathEntry(NonNullUtils.nullToEmptyString(owner), fTrace, getStartTime(), getEndTime(), owner);
parent.addChild(entry);
public void visit(TmfEdge link, boolean horizontal) {
if (horizontal) {
Object parent = fGraph.getParentOf(link.getVertexFrom());
- CriticalPathEntry entry = fRootList.get(parent);
+ CriticalPathEntry entry = checkNotNull(fRootList.get(parent));
TimeEvent ev = new TimeEvent(entry, link.getVertexFrom().getTs(), link.getDuration(),
getMatchingState(link.getType()).ordinal());
entry.addEvent(ev);
CompoundDeclaration declaration = (CompoundDeclaration) charArrayFixture.getDeclaration();
String fieldName = "";
- @SuppressWarnings("null")
ArrayDefinition result = new ArrayDefinition(declaration, this.trace, fieldName, Arrays.asList(new Definition[0]));
assertNotNull(result);
}
IDefinitionScope definitionScope = getDefinitionScope();
String fieldName = "";
- @SuppressWarnings("null")
ArrayDefinition result = new ArrayDefinition(declaration, definitionScope, fieldName, Arrays.asList(new Definition[0]));
assertNotNull(result);
}
* prev_state, string next_comm, int32 next_tid, int32 next_prio
*/
{
- int prevTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldPrevTid()).getValue()).intValue();
- int nextTid = ((Long) content.getField(fLayouts.get(event.getTrace()).fieldNextTid()).getValue()).intValue();
+ final IKernelAnalysisEventLayout eventLayout = fLayouts.get(event.getTrace());
+ if (eventLayout == null) {
+ return;
+ }
+ int prevTid = ((Long) content.getField(eventLayout.fieldPrevTid()).getValue()).intValue();
+ int nextTid = ((Long) content.getField(eventLayout.fieldNextTid()).getValue()).intValue();
if (host.isGuest()) {
/* Get the event's CPU */
return;
}
TmfPcapProtocol protocol = (TmfPcapProtocol) e.item.getData(KEY_PROTOCOL);
- tables.get(protocol).deselectAll();
+ final Table table = tables.get(protocol);
+ if (table != null) {
+ table.deselectAll();
+ }
fCurrentStream = null;
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.piecharts.model.TmfPieChartStatisticsModel;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
/**
* Creates a viewer containing 2 pie charts, one for showing information about
continue;
}
for (Entry<String, Long> event : traceEventCount.entrySet()) {
- if (totalEventCountForChart.containsKey(event.getKey())) {
- totalEventCountForChart.put(event.getKey(), totalEventCountForChart.get(event.getKey()) + event.getValue());
+ final Long value = totalEventCountForChart.get(event.getKey());
+ if (value != null) {
+ totalEventCountForChart.put(event.getKey(), value + event.getValue());
} else {
totalEventCountForChart.put(event.getKey(), event.getValue());
}
private void sortNodes(Map<String, List<GraphNode>> nodesToSort, Map.Entry<String, Boolean> sortMapEntry, boolean forward) {
String nodeType = sortMapEntry.getKey();
- GraphNode[] temp = nodesToSort.get(nodeType).toArray(new GraphNode[nodesToSort.get(nodeType).size()]);
- GraphNode node = fNodes.get(nodeType).get(0);
+ GraphNode[] temp = checkNotNull(nodesToSort.get(nodeType)).stream().toArray(GraphNode[]::new);
+ GraphNode node = checkNotNull(fNodes.get(nodeType)).get(0);
if (forward) {
Arrays.sort(temp, node.getComparator());
fNodes.put(nodeType, Arrays.asList(temp));