TMF: Add some non null annotations to TmfTimeRange
authorGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 5 Feb 2015 18:57:01 +0000 (13:57 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 6 Mar 2015 23:28:08 +0000 (18:28 -0500)
And all the required changes and extra annotations to fix all the warnings

Change-Id: Ic6f58052550f5f4fcca119ecf6c6d3e2e16d3631
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/41240
Reviewed-by: Hudson CI
21 files changed:
org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/build.properties
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimeRangeTest.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/signal/TmfTimeSynchSignal.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/ITmfTimestamp.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimeRange.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceContext.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpointIndexer.java
org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java
org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java
org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/build.properties
org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java
org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/DrawableToolTip.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java

index f6ae25f5ad366bae759df6018bdcc2bed67628ed..cee367fdce9ca2f94596e03961d68fb29a85e73d 100644 (file)
@@ -15,3 +15,5 @@ bin.includes = META-INF/,\
                .,\
                plugin.properties,\
                about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
index 8bf52a3ad121c993f8f0c3ede7863520b2fa503b..5dec30244cd8b35724eb56a651b885d91caccdf9 100644 (file)
@@ -17,7 +17,6 @@ package org.eclipse.tracecompass.tmf.core.tests.event;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
@@ -44,23 +43,6 @@ public class TmfTimeRangeTest {
         assertEquals("endTime", ts2, range.getEndTime());
     }
 
-    @Test
-    public void testBadConstructor() {
-        try {
-            new TmfTimeRange(TmfTimestamp.BIG_BANG, null);
-            fail("TmfTimeRange: bad end time");
-        } catch (final IllegalArgumentException e) {
-            // Success
-        }
-
-        try {
-            new TmfTimeRange(null, TmfTimestamp.BIG_CRUNCH);
-            fail("TmfTimeRange: bad start time");
-        } catch (final IllegalArgumentException e) {
-            // Success
-        }
-    }
-
     @Test
     public void testOpenRange1() {
         final ITmfTimestamp ts2 = new TmfTimestamp(12350);
@@ -104,16 +86,6 @@ public class TmfTimeRangeTest {
         assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range3.getEndTime());
     }
 
-    @Test
-    public void testCopyConstructor2() {
-        try {
-            new TmfTimeRange(null);
-            fail("TmfTimeRange: null argument");
-        } catch (final IllegalArgumentException e) {
-            // Success
-        }
-    }
-
     // ------------------------------------------------------------------------
     // hashCode
     // ------------------------------------------------------------------------
index fb13dca521d9ab5fda1212a6f73a74d1f5297fe6..161b74d0b875a2c16e657352f598c829bb880eda 100644 (file)
 
 package org.eclipse.tracecompass.tmf.core.signal;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 
 /**
@@ -23,6 +27,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
  *
  * @author Francois Chouinard
 */
+@NonNullByDefault
 public class TmfTimeSynchSignal extends TmfSignal {
 
     private final ITmfTimestamp fBeginTime;
@@ -36,7 +41,7 @@ public class TmfTimeSynchSignal extends TmfSignal {
      * @param ts
      *            Timestamp of selection
      */
-    public TmfTimeSynchSignal(Object source, ITmfTimestamp ts) {
+    public TmfTimeSynchSignal(@Nullable Object source, ITmfTimestamp ts) {
         super(source);
         fBeginTime = ts;
         fEndTime = ts;
@@ -52,7 +57,7 @@ public class TmfTimeSynchSignal extends TmfSignal {
      * @param end
      *            Timestamp of end of selection range
      */
-    public TmfTimeSynchSignal(Object source, ITmfTimestamp begin, ITmfTimestamp end) {
+    public TmfTimeSynchSignal(@Nullable Object source, ITmfTimestamp begin, ITmfTimestamp end) {
         super(source);
         fBeginTime = begin;
         fEndTime = end;
@@ -76,15 +81,13 @@ public class TmfTimeSynchSignal extends TmfSignal {
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("[TmfTimeSynchSignal ("); //$NON-NLS-1$
-        if (fBeginTime != null) {
-            sb.append(fBeginTime.toString());
-            if (!fBeginTime.equals(fEndTime) && fEndTime != null) {
-                sb.append('-');
-                sb.append(fEndTime.toString());
-            }
+        sb.append(fBeginTime.toString());
+        if (!fBeginTime.equals(fEndTime)) {
+            sb.append('-');
+            sb.append(fEndTime.toString());
         }
         sb.append(")]"); //$NON-NLS-1$
-        return sb.toString();
+        return checkNotNull(sb.toString());
     }
 
 }
index e78ec19423f8c03f29f4ae272cbeb2610324e9f2..c9981a64ba72581866399de934fc5ec14bec21cb 100644 (file)
@@ -410,10 +410,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
         fTimeRange = TmfTimeRange.ETERNITY;
         final ITmfTrace trace = provider.getTrace();
         if (!isCompleteTrace(trace)) {
-            TmfTimeRange traceTimeRange = trace.getTimeRange();
-            if (traceTimeRange != null) {
-                fTimeRange = traceTimeRange;
-            }
+            fTimeRange = trace.getTimeRange();
         }
 
         fStateProvider = provider;
index 1d62a57fa489fc6737ad44004fea253d2412fd39..cc6e79ac049e5dc50ca951216fe72483e77c1841 100644 (file)
@@ -96,7 +96,7 @@ public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
      * @param ts the other timestamp
      * @return the time difference (this - other) as an ITmfTimestamp
      */
-    ITmfTimestamp getDelta(ITmfTimestamp ts);
+    @NonNull ITmfTimestamp getDelta(ITmfTimestamp ts);
 
     /**
      * Returns if this timestamp intersects the given time range. Borders are
index 308c98eabb2ba3016b7c730075920c45f2a0f101..1f45f578378055ee03db4f3fd5c4ae4bf3a23a43 100644 (file)
@@ -14,6 +14,8 @@
 package org.eclipse.tracecompass.tmf.core.timestamp;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 
 /**
  * A utility class to define and manage time ranges.
@@ -22,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNull;
  *
  * @see ITmfTimestamp
  */
+@NonNullByDefault
 public class TmfTimeRange {
 
     // ------------------------------------------------------------------------
@@ -31,12 +34,12 @@ public class TmfTimeRange {
     /**
      * The full possible time range
      */
-    public static final @NonNull TmfTimeRange ETERNITY = new EternityTimeRange();
+    public static final TmfTimeRange ETERNITY = new EternityTimeRange();
 
     /**
      * The null time range
      */
-    public static final @NonNull TmfTimeRange NULL_RANGE = new TmfTimeRange();
+    public static final TmfTimeRange NULL_RANGE = new TmfTimeRange();
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -64,9 +67,6 @@ public class TmfTimeRange {
      * @param endTime end of the time range
      */
     public TmfTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
-        if (startTime == null || endTime == null) {
-            throw new IllegalArgumentException();
-        }
         fStartTime = startTime;
         fEndTime = endTime;
     }
@@ -77,9 +77,6 @@ public class TmfTimeRange {
      * @param range the other time range
      */
     public TmfTimeRange(final TmfTimeRange range) {
-        if (range == null) {
-            throw new IllegalArgumentException();
-        }
         fStartTime = range.getStartTime();
         fEndTime = range.getEndTime();
     }
@@ -140,7 +137,7 @@ public class TmfTimeRange {
      * @param range the other time range
      * @return the intersection time range, or null if no intersection exists
      */
-    public TmfTimeRange getIntersection(final TmfTimeRange range) {
+    public @Nullable TmfTimeRange getIntersection(final TmfTimeRange range) {
         if (fStartTime.compareTo(range.fEndTime) > 0 || fEndTime.compareTo(range.fStartTime) < 0) {
             return null; // no intersection
         }
@@ -166,7 +163,7 @@ public class TmfTimeRange {
     }
 
     @Override
-    public boolean equals(final Object obj) {
+    public boolean equals(final @Nullable Object obj) {
         if (this == obj) {
             return true;
         }
@@ -217,7 +214,7 @@ public class TmfTimeRange {
         }
 
         @Override
-        public TmfTimeRange getIntersection(TmfTimeRange range) {
+        public @NonNull TmfTimeRange getIntersection(TmfTimeRange range) {
             return range;
         }
     }
index f8e3efceac415e70e6dcead9059696ebacd3a55f..7d2d768f691e4a3b6d946f24aff226c0ffb4be35 100644 (file)
@@ -286,17 +286,17 @@ public interface ITmfTrace extends ITmfEventProvider {
     /**
      * @return the trace time range
      */
-    TmfTimeRange getTimeRange();
+    @NonNull TmfTimeRange getTimeRange();
 
     /**
      * @return the timestamp of the first trace event
      */
-    ITmfTimestamp getStartTime();
+    @NonNull ITmfTimestamp getStartTime();
 
     /**
      * @return the timestamp of the last trace event
      */
-    ITmfTimestamp getEndTime();
+    @NonNull ITmfTimestamp getEndTime();
 
     /**
      * @return the streaming interval in ms (0 if not a streaming trace)
@@ -431,6 +431,6 @@ public interface ITmfTrace extends ITmfEventProvider {
      *            The time in nanoseconds with which to create the timestamp
      * @return The new timestamp
      */
-    ITmfTimestamp createTimestamp(long ts);
+    @NonNull ITmfTimestamp createTimestamp(long ts);
 
 }
index bafae0346d87d07d373bd60d2bc5cd1842def6bb..16f60f00a3b4e8e8da598346432141dada0cc14c 100644 (file)
@@ -124,8 +124,8 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     private volatile long fNbEvents = 0;
 
     // The time span of the event stream
-    private ITmfTimestamp fStartTime = TmfTimestamp.BIG_BANG;
-    private ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
+    private @NonNull ITmfTimestamp fStartTime = TmfTimestamp.BIG_BANG;
+    private @NonNull ITmfTimestamp fEndTime = TmfTimestamp.BIG_BANG;
 
     // The trace streaming interval (0 = no streaming)
     private long fStreamingInterval = 0;
@@ -392,7 +392,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     }
 
     @Override
-    public TmfTimeRange getTimeRange() {
+    public @NonNull TmfTimeRange getTimeRange() {
         return new TmfTimeRange(fStartTime, fEndTime);
     }
 
@@ -445,7 +445,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
      *
      * @param range the new time range
      */
-    protected void setTimeRange(final TmfTimeRange range) {
+    protected void setTimeRange(final @NonNull TmfTimeRange range) {
         fStartTime = range.getStartTime();
         fEndTime = range.getEndTime();
     }
@@ -455,7 +455,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
      *
      * @param startTime the new first event timestamp
      */
-    protected void setStartTime(final ITmfTimestamp startTime) {
+    protected void setStartTime(final @NonNull ITmfTimestamp startTime) {
         fStartTime = startTime;
     }
 
@@ -464,7 +464,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
      *
      * @param endTime the new last event timestamp
      */
-    protected void setEndTime(final ITmfTimestamp endTime) {
+    protected void setEndTime(final @NonNull ITmfTimestamp endTime) {
         fEndTime = endTime;
     }
 
@@ -550,7 +550,8 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
         // parseEvent() does not update the context
         final ITmfEvent event = parseEvent(context);
         if (event != null) {
-            updateAttributes(context, event.getTimestamp());
+            ITmfTimestamp timestamp = event.getTimestamp();
+            updateAttributes(context, timestamp);
             context.setLocation(getCurrentLocation());
             context.increaseRank();
         }
@@ -563,7 +564,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
      * @param context the current trace context
      * @param timestamp the corresponding timestamp
      */
-    protected synchronized void updateAttributes(final ITmfContext context, final ITmfTimestamp timestamp) {
+    protected synchronized void updateAttributes(final ITmfContext context, final @NonNull ITmfTimestamp timestamp) {
         if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp) > 0)) {
             fStartTime = timestamp;
         }
@@ -704,7 +705,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     }
 
     @Override
-    public ITmfTimestamp createTimestamp(long ts) {
+    public @NonNull ITmfTimestamp createTimestamp(long ts) {
         return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
     }
 
index 7a214e61654f698cc2f10c116b6150016a939e44..f5eaf4965f33ad69bbc9b09e01c9e48e9315e983 100644 (file)
@@ -15,6 +15,8 @@
 package org.eclipse.tracecompass.tmf.core.trace;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
@@ -28,6 +30,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
  *
  * @author Alexandre Montplaisir
  */
+@NonNullByDefault
 final class TmfTraceContext {
 
     static final TmfTraceContext NULL_CONTEXT =
@@ -35,10 +38,10 @@ final class TmfTraceContext {
 
     private final TmfTimeRange fSelection;
     private final TmfTimeRange fWindowRange;
-    private final IFile fEditorFile;
-    private final ITmfFilter fFilter;
+    private final @Nullable IFile fEditorFile;
+    private final @Nullable ITmfFilter fFilter;
 
-    public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr, IFile editorFile) {
+    public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr, @Nullable IFile editorFile) {
         fSelection = new TmfTimeRange(beginTs, endTs);
         fWindowRange = tr;
         fEditorFile = editorFile;
@@ -65,7 +68,7 @@ final class TmfTraceContext {
      * @param filter
      *              The applied filter
      */
-    public TmfTraceContext(TmfTraceContext prevCtx, ITmfFilter filter) {
+    public TmfTraceContext(TmfTraceContext prevCtx, @Nullable ITmfFilter filter) {
         fSelection = prevCtx.fSelection;
         fWindowRange = prevCtx.fWindowRange;
         fEditorFile = prevCtx.fEditorFile;
@@ -84,14 +87,14 @@ final class TmfTraceContext {
         return fWindowRange;
     }
 
-    public IFile getEditorFile() {
+    public @Nullable IFile getEditorFile() {
         return fEditorFile;
     }
 
     /**
      * @return the current filter applied to the trace
      */
-    public ITmfFilter getFilter() {
+    public @Nullable ITmfFilter getFilter() {
         return fFilter;
     }
 
index b471099fccc9cec1c8b82b9feae46717b4be8a72..9a061862fdb90e2a2fdae1bc96d0551ed4cb00d1 100644 (file)
@@ -107,14 +107,14 @@ public final class TmfTraceManager {
     /**
      * @return The begin timestamp of selection
      */
-    public ITmfTimestamp getSelectionBeginTime() {
+    public @NonNull ITmfTimestamp getSelectionBeginTime() {
         return getCurrentTraceContext().getSelectionBegin();
     }
 
     /**
      * @return The end timestamp of selection
      */
-    public ITmfTimestamp getSelectionEndTime() {
+    public @NonNull ITmfTimestamp getSelectionEndTime() {
         return getCurrentTraceContext().getSelectionEnd();
     }
 
@@ -180,7 +180,7 @@ public final class TmfTraceManager {
         return null;
     }
 
-    private TmfTraceContext getCurrentTraceContext() {
+    private @NonNull TmfTraceContext getCurrentTraceContext() {
         TmfTraceContext curCtx = fTraces.get(fCurrentTrace);
         if (curCtx == null) {
             /* There are no traces opened at the moment. */
@@ -387,7 +387,7 @@ public final class TmfTraceManager {
         for (Map.Entry<ITmfTrace, TmfTraceContext> entry : fTraces.entrySet()) {
             final ITmfTrace trace = entry.getKey();
             if (beginTs.intersects(getValidTimeRange(trace)) || endTs.intersects(getValidTimeRange(trace))) {
-                TmfTraceContext prevCtx = entry.getValue();
+                TmfTraceContext prevCtx = NonNullUtils.checkNotNull(entry.getValue());
                 TmfTraceContext newCtx = new TmfTraceContext(prevCtx, beginTs, endTs);
                 entry.setValue(newCtx);
             }
@@ -407,12 +407,15 @@ public final class TmfTraceManager {
     public synchronized void timeRangeUpdated(final TmfRangeSynchSignal signal) {
         for (Map.Entry<ITmfTrace, TmfTraceContext> entry : fTraces.entrySet()) {
             final ITmfTrace trace = entry.getKey();
-            final TmfTraceContext curCtx = entry.getValue();
+            final TmfTraceContext curCtx = NonNullUtils.checkNotNull(entry.getValue());
 
             final TmfTimeRange validTr = getValidTimeRange(trace);
 
             /* Determine the new time range */
-            TmfTimeRange targetTr = signal.getCurrentRange().getIntersection(validTr);
+            TmfTimeRange targetTr = null;
+            if (validTr != null) {
+                targetTr = signal.getCurrentRange().getIntersection(validTr);
+            }
             TmfTimeRange newTr = (targetTr == null ? curCtx.getWindowRange() : targetTr);
 
             /* Update the values */
index 5c44bc95f5d8c88d7c8289cd802156b01a454c94..86f41710475eb44b6c2cd1b364be556f9897613d 100644 (file)
@@ -600,9 +600,10 @@ public class TmfExperiment extends TmfTrace implements ITmfPersistentlyIndexable
                                 endTimestamp = trace.getEndTime();
                             }
                         }
-                        if (safeTimestamp != null && (lastSafeTimestamp == null || safeTimestamp.compareTo(lastSafeTimestamp) > 0)) {
-                            timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
-                            lastSafeTimestamp = safeTimestamp;
+                        ITmfTimestamp safeTs = safeTimestamp;
+                        if (safeTs != null && (lastSafeTimestamp == null || safeTs.compareTo(lastSafeTimestamp) > 0)) {
+                            timeRange = new TmfTimeRange(startTimestamp, safeTs);
+                            lastSafeTimestamp = safeTs;
                         } else {
                             timeRange = null;
                         }
index 093d95b472dc421345dd3661761c2f99a20aa11a..bfc06cb332cce09f61357c0f2c4a868e3c0f4f18 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Messages;
 import org.eclipse.tracecompass.internal.tmf.core.trace.indexer.TmfMemoryIndex;
 import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
@@ -239,7 +240,7 @@ public class TmfCheckpointIndexer implements ITmfTraceIndexer {
      * @param startTime the new start time
      * @param endTime the new end time
      */
-    private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
+    private void signalNewTimeRange(final @NonNull ITmfTimestamp startTime, final @NonNull ITmfTimestamp endTime) {
         fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime), fTrace.getNbEvents()));
     }
 
index 7d1af7dd0650531c7bbc0132b05e4f42a9d2ec2c..af2fc0556991eba874268551e400efaec16f54ea 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
@@ -176,7 +177,7 @@ public class CtfTmfLostEventsTest {
         return req.getEvent();
     }
 
-    private CtfTmfEvent getOneEventTime(ITmfTimestamp ts) {
+    private CtfTmfEvent getOneEventTime(@NonNull ITmfTimestamp ts) {
         OneEventRequestPerTs req = new OneEventRequestPerTs(ts);
         fixture.sendRequest(req);
         try {
@@ -210,7 +211,7 @@ public class CtfTmfLostEventsTest {
 
         private CtfTmfEvent event = null;
 
-        public OneEventRequestPerTs(ITmfTimestamp ts) {
+        public OneEventRequestPerTs(@NonNull ITmfTimestamp ts) {
             super(CtfTmfEvent.class,
                     new TmfTimeRange(ts, TmfTimestamp.BIG_CRUNCH),
                     0, 1, ExecutionType.FOREGROUND);
index 03f03eec18f8d82488fb594d3a8ec6766dafa2c7..9cc5927c4c6e331d8f7ab6f339fe81beb25aaa1e 100644 (file)
@@ -22,6 +22,7 @@ import java.io.File;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
@@ -142,7 +143,7 @@ public class TmfTraceManagerTest {
         TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, trace));
     }
 
-    private void selectTimestamp(ITmfTimestamp ts) {
+    private void selectTimestamp(@NonNull ITmfTimestamp ts) {
         TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, ts));
     }
 
@@ -713,7 +714,7 @@ public class TmfTraceManagerTest {
     /**
      * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
      */
-    private static ITmfTimestamp calculateOffset(ITmfTimestamp initialTs, ITmfTimestamp offsetTs) {
+    private static @NonNull ITmfTimestamp calculateOffset(ITmfTimestamp initialTs, ITmfTimestamp offsetTs) {
         long start = initialTs.normalize(0, SCALE).getValue();
         long offset = offsetTs.normalize(0, SCALE).getValue();
         return new TmfTimestamp(start + offset, SCALE);
index e0d913299467e1882e0e06f12876960cc5d14fd5..3efb9dfb2c2060d8a119805980bf8205d5b66f25 100644 (file)
@@ -584,7 +584,7 @@ public class CtfTmfTrace extends TmfTrace
     // ------------------------------------------------------------------------
 
     @Override
-    public CtfTmfTimestamp createTimestamp(long ts) {
+    public @NonNull CtfTmfTimestamp createTimestamp(long ts) {
         return new CtfTmfTimestamp(getTimestampTransform().transform(ts));
     }
 
index 308a5fb81173bc49743858d537d04694ed0255cc..1a4decb3955d2958eedbc4818bf274cfdeb69409 100644 (file)
@@ -17,3 +17,5 @@ bin.includes = META-INF/,\
                plugin.properties,\
                about.html
 src.includes = about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
index 8b8a3ae11eeb19edec273e4b9c35801d23137aa4..dd6cb0e66e6b2b06eed1fb9e5993777d3f817f6e 100644 (file)
@@ -39,7 +39,6 @@ public class TmfUml2SDSyncLoaderSignalTest {
 
     private static TmfTimeRange range;
     private static TmfTimestamp rangeWindow;
-    private static TmfTimestamp currentTime;
 
     /**
      * Initialization
@@ -52,7 +51,7 @@ public class TmfUml2SDSyncLoaderSignalTest {
         range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
         // Get range window for tests below
         rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
-        currentTime = new Uml2SDTestTimestamp(9789773782043L);
+        TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
 
         fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range));
         fFacility.getTrace().broadcast(new TmfTimeSynchSignal(fFacility, currentTime));
@@ -78,7 +77,7 @@ public class TmfUml2SDSyncLoaderSignalTest {
      */
     @Test
     public void verifyFirstPageSignal() {
-        currentTime = new Uml2SDTestTimestamp(9788641608418L);
+        TmfTimestamp currentTime = new Uml2SDTestTimestamp(9788641608418L);
         range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue()));
 
         fTmfComponent.setSignalError(false);
index be67b8a3e8e4ee4011062b61f0d40829669fe59c..5a3f56d72d95ba28ff86c107a424b84531d00084 100644 (file)
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTimeSynchSignal;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
@@ -42,7 +43,7 @@ public class TmfUml2SDSyncLoaderTimeTest {
     // ------------------------------------------------------------------------
 
     // Test case 001 expected values
-    final static private Uml2SDTestTimestamp TC_001_TIME_VALUE       = new Uml2SDTestTimestamp(9788642228395L);
+    final static private @NonNull Uml2SDTestTimestamp TC_001_TIME_VALUE       = new Uml2SDTestTimestamp(9788642228395L);
     final static private String              TC_001_MESSAGE_NAME     = "START_GAME_REPLY";
     final static private int                 TC_001_PAGE_VALUE       = 0;
     final static private int                 TC_001_START_OCCURRANCE = 6;
@@ -51,7 +52,7 @@ public class TmfUml2SDSyncLoaderTimeTest {
     final static private String              TC_001_END_LIFELINE     = IUml2SDTestConstants.FIRST_PLAYER_NAME;
 
     // Test case 002 expected values
-    final static private Uml2SDTestTimestamp TC_002_TIME_VALUE       = new Uml2SDTestTimestamp(9789689830722L);
+    final static private @NonNull Uml2SDTestTimestamp TC_002_TIME_VALUE       = new Uml2SDTestTimestamp(9789689830722L);
     final static private String              TC_002_MESSAGE_NAME     = "PAUSE_GAME_REQUEST";
     final static private int                 TC_002_PAGE_VALUE       = 2;
     final static private int                 TC_002_START_OCCURRANCE = 7;
@@ -60,7 +61,7 @@ public class TmfUml2SDSyncLoaderTimeTest {
     final static private String              TC_002_END_LIFELINE     = IUml2SDTestConstants.MASTER_PLAYER_NAME;
 
     // Test case 003 expected values
-    final static private Uml2SDTestTimestamp TC_003_TIME_VALUE       = new Uml2SDTestTimestamp(9790750000000L);
+    final static private @NonNull Uml2SDTestTimestamp TC_003_TIME_VALUE       = new Uml2SDTestTimestamp(9790750000000L);
     final static private int                 TC_003_PAGE_VALUE       = 4;
 
     // Test case 004 expected values
@@ -70,28 +71,28 @@ public class TmfUml2SDSyncLoaderTimeTest {
     final static private int                 TC_005_PAGE_VALUE       = IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1;
 
     // Test case 006 expected values
-    final static private Uml2SDTestTimestamp TC_006_TIME_VALUE       = new Uml2SDTestTimestamp(9792420661655L);
+    final static private @NonNull Uml2SDTestTimestamp TC_006_TIME_VALUE       = new Uml2SDTestTimestamp(9792420661655L);
     final static private int                 TC_006_PAGE_VALUE       = 4;
     final static private int                 TC_006_START_OCCURRANCE = IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE;
     final static private int                 TC_006_END_OCCURRANCE   = TC_006_START_OCCURRANCE;
 
     // Test case 007 expected values
-    final static private Uml2SDTestTimestamp TC_007_TIME_VALUE       = new Uml2SDTestTimestamp(9792420756010L);
+    final static private @NonNull Uml2SDTestTimestamp TC_007_TIME_VALUE       = new Uml2SDTestTimestamp(9792420756010L);
     final static private int                 TC_007_PAGE_VALUE       = 5;
     final static private int                 TC_007_START_OCCURRANCE = 1;
     final static private int                 TC_007_END_OCCURRANCE   = TC_007_START_OCCURRANCE;
 
     // Test case 008 expected values
-    final static private Uml2SDTestTimestamp TC_008_TIME_VALUE       = new Uml2SDTestTimestamp(9788642228395L);
+    final static private @NonNull Uml2SDTestTimestamp TC_008_TIME_VALUE       = new Uml2SDTestTimestamp(9788642228395L);
     final static private int                 TC_008_PAGE_VALUE       = 0;
-    final static private Uml2SDTestTimestamp TC_008_START_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L);
-    final static private Uml2SDTestTimestamp TC_008_END_TIME_VALUE   = new Uml2SDTestTimestamp(9789164833324L);
+    final static private @NonNull Uml2SDTestTimestamp TC_008_START_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L);
+    final static private @NonNull Uml2SDTestTimestamp TC_008_END_TIME_VALUE   = new Uml2SDTestTimestamp(9789164833324L);
 
     // Test case 009 expected values
-    final static private Uml2SDTestTimestamp TC_009_TIME_VALUE       = new Uml2SDTestTimestamp(9789689220871L);
+    final static private @NonNull Uml2SDTestTimestamp TC_009_TIME_VALUE       = new Uml2SDTestTimestamp(9789689220871L);
     final static private int                 TC_009_PAGE_VALUE       = 1;
-    final static private Uml2SDTestTimestamp TC_009_START_TIME_VALUE = TC_009_TIME_VALUE;
-    final static private Uml2SDTestTimestamp TC_009_END_TIME_VALUE   = new Uml2SDTestTimestamp(9789773881426L);
+    final static private @NonNull Uml2SDTestTimestamp TC_009_START_TIME_VALUE = TC_009_TIME_VALUE;
+    final static private @NonNull Uml2SDTestTimestamp TC_009_END_TIME_VALUE   = new Uml2SDTestTimestamp(9789773881426L);
 
     // Fields used in tests
     private static Uml2SDTestFacility fFacility;
index c95b22fedf0fc1c41b959c375732b62caace10f7..a38ca9a7789c1270cca411f44fcb732edbb4e3f3 100644 (file)
@@ -106,6 +106,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.Messages;
@@ -466,18 +467,19 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                         fRawViewer.selectAndReveal((Long) e.item.getData(Key.RANK));
                     }
                     if (e.item.getData(Key.TIMESTAMP) instanceof ITmfTimestamp) {
-                        final ITmfTimestamp ts = (ITmfTimestamp) e.item.getData(Key.TIMESTAMP);
+                        final ITmfTimestamp ts = NonNullUtils.checkNotNull((ITmfTimestamp) e.item.getData(Key.TIMESTAMP));
                         if (fTable.getSelectionIndices().length == 1) {
                             fSelectedBeginTimestamp = ts;
                         }
-                        if (fSelectedBeginTimestamp != null) {
-                            if (fSelectedBeginTimestamp.compareTo(ts) <= 0) {
-                                broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, fSelectedBeginTimestamp, ts));
+                        ITmfTimestamp selectedBeginTimestamp = fSelectedBeginTimestamp;
+                        if (selectedBeginTimestamp != null) {
+                            if (selectedBeginTimestamp.compareTo(ts) <= 0) {
+                                broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, selectedBeginTimestamp, ts));
                                 if (fTable.getSelectionIndices().length == 2) {
-                                    updateStatusLine(ts.getDelta(fSelectedBeginTimestamp));
+                                    updateStatusLine(ts.getDelta(selectedBeginTimestamp));
                                 }
                             } else {
-                                broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, ts, fSelectedBeginTimestamp));
+                                broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, checkNotNull(ts), checkNotNull(fSelectedBeginTimestamp)));
                                 updateStatusLine(fSelectedBeginTimestamp.getDelta(ts));
                             }
                         }
index 0163ba988990958352b00c8ba0066e6cf2f6cba1..da7673250a03b6619e849e04cfd0240898fee49b 100755 (executable)
@@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.util.Messages;
 
 /**
@@ -223,7 +224,15 @@ public class DrawableToolTip implements PaintListener {
      * @param max the scale max
      */
     public void showToolTip(ITmfTimestamp value, ITmfTimestamp min, ITmfTimestamp max) {
-        fMinMaxRange = new TmfTimeRange(min, max);
+        ITmfTimestamp minTime = min;
+        ITmfTimestamp maxTime = max;
+        if (minTime == null) {
+            minTime = TmfTimestamp.BIG_BANG;
+        }
+        if (maxTime == null) {
+            maxTime = TmfTimestamp.BIG_CRUNCH;
+        }
+        fMinMaxRange = new TmfTimeRange(minTime, maxTime);
         fCurrentValue = value;
 
         int w = fToolTipShell.getBounds().width;
index ba5e6cdb907203ee6cfe669b630ee60f48cf0537..49ac088db7eed60c3266c31ee8bb3fe5541ae231 100644 (file)
@@ -318,20 +318,24 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
                     super.handleData(event);
 
                     ITmfSyncSequenceDiagramEvent sdEvent = getSequenceDiagramEvent(event);
+                    ITmfTimestamp firstTime = fFirstTime;
+                    ITmfTimestamp lastTime = fLastTime;
 
                     if (sdEvent != null) {
                         ++fNbSeqEvents;
 
-                        if (fFirstTime == null) {
-                            fFirstTime = event.getTimestamp();
+                        if (firstTime == null) {
+                            firstTime = event.getTimestamp();
+                            fFirstTime = firstTime;
                         }
 
-                        fLastTime = event.getTimestamp();
+                        lastTime = event.getTimestamp();
+                        fLastTime = lastTime;
 
                         if ((fNbSeqEvents % MAX_NUM_OF_MSG) == 0) {
                             fLock.lock();
                             try {
-                                fCheckPoints.add(new TmfTimeRange(fFirstTime, fLastTime));
+                                fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                                 if (fView != null) {
                                     fView.updateCoolBar();
                                 }
@@ -357,11 +361,13 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
 
                 @Override
                 public void handleSuccess() {
-                    if ((fFirstTime != null) && (fLastTime != null)) {
+                    final ITmfTimestamp firstTime = fFirstTime;
+                    final ITmfTimestamp lastTime = fLastTime;
+                    if ((firstTime != null) && (lastTime != null)) {
 
                         fLock.lock();
                         try {
-                            fCheckPoints.add(new TmfTimeRange(fFirstTime, fLastTime));
+                            fCheckPoints.add(new TmfTimeRange(firstTime, lastTime));
                             if (fView != null) {
                                 fView.updateCoolBar();
                             }
@@ -577,7 +583,11 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
             StructuredSelection stSel = (StructuredSelection) sel;
             if (stSel.getFirstElement() instanceof TmfSyncMessage) {
                 TmfSyncMessage syncMsg = ((TmfSyncMessage) stSel.getFirstElement());
-                broadcast(new TmfTimeSynchSignal(this, syncMsg.getStartTime()));
+                ITmfTimestamp startTime = syncMsg.getStartTime();
+                if (startTime == null) {
+                    startTime = TmfTimestamp.BIG_BANG;
+                }
+                broadcast(new TmfTimeSynchSignal(this, startTime));
             }
         }
     }
This page took 0.04168 seconds and 5 git commands to generate.