Skip to content

Commit

Permalink
tmf: remove unnecessary cast
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaud Fiorini <[email protected]>
  • Loading branch information
arfio authored and MatthewKhouzam committed Nov 4, 2024
1 parent 1736c2f commit 871c450
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;

Expand Down Expand Up @@ -131,7 +130,7 @@ protected void deleteTrace() {
}

deleteSuppFiles(trace);
((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fTrace = trace;

/* Start the kernel analysis module */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class FlameChartDataProviderFactory implements IDataProviderFactory {
// The trace can be an experiment, so we need to know if there are
// multiple analysis modules with the same ID
Iterable<IFlameChartProvider> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, IFlameChartProvider.class);
Iterable<IFlameChartProvider> filteredModules = Iterables.filter(modules, m -> ((IAnalysisModule) m).getId().equals(secondaryId));
Iterable<IFlameChartProvider> filteredModules = Iterables.filter(modules, m -> m.getId().equals(secondaryId));
Iterator<IFlameChartProvider> iterator = filteredModules.iterator();
if (iterator.hasNext()) {
IFlameChartProvider module = iterator.next();
Expand All @@ -82,7 +82,7 @@ public class FlameChartDataProviderFactory implements IDataProviderFactory {
// the factory can try with individual traces
return null;
}
((IAnalysisModule) module).schedule();
module.schedule();
return new FlameChartDataProvider(trace, module, secondaryId);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
Expand Down Expand Up @@ -92,7 +91,7 @@ public static void setUp() {

final CtfTestTrace cygProfile = CtfTestTrace.CYG_PROFILE;
LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(cygProfile);
fStart = ((CtfTmfTrace) trace).getStartTime().toNanos();
fStart = trace.getStartTime().toNanos();
fFullRange = new TmfTimeRange(TmfTimestamp.fromNanos(fStart), TmfTimestamp.fromNanos(fStart + 100l));
final File file = new File(trace.getPath());
LttngUstTestTraceUtils.dispose(cygProfile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public XmlXYView() {

TmfXYChartViewer chart = getChartViewer();
if (chart instanceof XmlXYViewer) {
((XmlXYViewer) chart).reset();
chart.reset();
}

loadTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.IntegerRangeCondition;
import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.TimeRangeCondition;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.backend.IPartialStateHistoryBackend;
import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
Expand Down Expand Up @@ -303,7 +302,7 @@ public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t)
* Now, we have the intervals with their real end times written to the
* backend, we should be able to get them from there
*/
List<ITmfStateInterval> intervalsList = ((ITmfStateSystem) fPartialSS).queryFullState(t);
List<ITmfStateInterval> intervalsList = fPartialSS.queryFullState(t);

for (int i = 0; i < currentStateInfo.size(); i++) {
ITmfStateInterval interval = currentStateInfo.get(i);
Expand All @@ -320,7 +319,7 @@ public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t)
* upper checkpoint exists
*/
if (fCheckpoints.ceilingKey(t) != null) {
intervalsList = prepareIntervalList(((ITmfStateSystem) fPartialSS).getNbAttributes());
intervalsList = prepareIntervalList(fPartialSS.getNbAttributes());
filledStateInfo.clear();
try {
fInnerHistory.doQuery(intervalsList, checkpointTime2);
Expand Down Expand Up @@ -366,7 +365,7 @@ public ITmfStateInterval doSingularQuery(long t, int attributeQuark) throws Time

/* Reload the previous checkpoint */
long checkpointTime = fCheckpoints.floorKey(t);
int nbAtributes = ((ITmfStateSystem)fPartialSS).getNbAttributes();
int nbAtributes = fPartialSS.getNbAttributes();
List<ITmfStateInterval> intervalsList = prepareIntervalList(nbAtributes);

/* Checking if the interval was stored in the real backend */
Expand Down Expand Up @@ -416,7 +415,7 @@ public ITmfStateInterval doSingularQuery(long t, int attributeQuark) throws Time
}

/* Querying the partial history at the lowerCheckpoint */
List<@Nullable ITmfStateInterval> currentStateInfo = prepareIntervalList(((ITmfStateSystem)fPartialSS).getNbAttributes());
List<@Nullable ITmfStateInterval> currentStateInfo = prepareIntervalList(fPartialSS.getNbAttributes());
try {
fInnerHistory.doQuery(currentStateInfo, lowerCheckpoint);
} catch (StateSystemDisposedException e) {
Expand Down Expand Up @@ -469,7 +468,7 @@ public ITmfStateInterval doSingularQuery(long t, int attributeQuark) throws Time
Logger logger = Logger.getAnonymousLogger();
try {
synchronized (fPartialSS) {
for (ITmfStateInterval interval : ((ITmfStateSystem) fPartialSS).query2D(quarksColletion, min, max)) {
for (ITmfStateInterval interval : fPartialSS.query2D(quarksColletion, min, max)) {
fCurrentIntervals.add(interval);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public synchronized ITmfContext seekEvent(final ITmfLocation location) {
traceContext.setRank(ranks[i]);
// update location after seek
locations[i] = traceContext.getLocation();
context.setContent(i, traceContext, ((ITmfTrace) getChild(i)).getNext(traceContext));
context.setContent(i, traceContext, getChild(i).getNext(traceContext));
rank += ranks[i];
}

Expand Down Expand Up @@ -627,7 +627,7 @@ public synchronized ITmfEvent getNext(ITmfContext context) {
trace, traceContext.getLocation(), traceContext.getRank());
experimentContext.setLocation(new TmfExperimentLocation(locationArray));
// queue the next event
ITmfEvent nextEvent = ((ITmfTrace) getChild(trace)).getNext(traceContext);
ITmfEvent nextEvent = getChild(trace).getNext(traceContext);
experimentContext.setContent(trace, traceContext, nextEvent);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,15 @@ private boolean handleTracesConflict(List<TracePackageTraceElement> traceElement
private static void uncheckTraceElement(TracePackageTraceElement traceElement) {
for (TracePackageElement e : traceElement.getChildren()) {
if (e instanceof TracePackageFilesElement) {
((TracePackageFilesElement) e).setChecked(false);
e.setChecked(false);
}
}
}

private static void uncheckExperimentElement(TracePackageExperimentElement experimentElement, List<TracePackageTraceElement> expTraceElements) {
for (TracePackageElement e : experimentElement.getChildren()) {
if (e instanceof TracePackageFilesElement) {
((TracePackageFilesElement) e).setChecked(false);
e.setChecked(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected synchronized void refreshChildren() {
IPath path = tracesFolder.getPath();
IResource resource = getResource();
if (resource instanceof IFolder) {
path = ((IFolder) resource).getFullPath();
path = resource.getFullPath();
}

IAnalysisModule module = getAnalysisModule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
Expand Down Expand Up @@ -354,7 +353,7 @@ public int getFilteredIndex() {
}

request = new DataRequest(ITmfEvent.class, filter, startRank, ITmfEventRequest.ALL_DATA);
((ITmfEventProvider) fTrace).sendRequest(request);
fTrace.sendRequest(request);
try {
request.waitForCompletion();
return ((DataRequest) request).getFilteredIndex();
Expand Down Expand Up @@ -461,7 +460,7 @@ public void handleData(ITmfEvent event) {
}
};

((ITmfEventProvider) fTrace).sendRequest(request);
fTrace.sendRequest(request);
try {
request.waitForCompletion();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void drawStyleLine(GC gc, Color lineColor, int imageWidth, int imageHeig
LineStyle lineStyle = LineStyle.valueOf((String) presProvider.getStyleOrDefault(appearance, StyleProperties.SERIES_STYLE, StyleProperties.SeriesStyle.SOLID));
if (lineStyle != LineStyle.NONE) {
gc.setForeground(lineColor);
gc.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue());
gc.setLineWidth(presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f).intValue());
gc.setLineStyle(lineStyle.ordinal());
gc.drawLine(0, imageHeight / 2, imageWidth, imageHeight / 2);
gc.setForeground(prev);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private double[] extractXValuesToDisplay(long[] xValuesRequested) {
lineSeries.setLineColor(color);
lineSeries.setSymbolColor(color);
lineSeries.setVisible(true);
lineSeries.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue());
lineSeries.setLineWidth(presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f).intValue());
return lineSeries;
}

Expand Down Expand Up @@ -674,7 +674,7 @@ private double[] extractXValuesToDisplay(long[] xValuesRequested) {
lineSeries.setLineColor(color);
lineSeries.setSymbolColor(color);
lineSeries.setVisible(true);
lineSeries.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue());
lineSeries.setLineWidth(presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f).intValue());
return lineSeries;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private SearchOptions getSearchOptions(boolean forwardSearch) {
*/
private static void setGridData(Control component, int horizontalAlignment, boolean grabExcessHorizontalSpace, int verticalAlignment, boolean grabExcessVerticalSpace) {
GridData gd;
if (component instanceof Button && (((Button) component).getStyle() & SWT.PUSH) != 0) {
if (component instanceof Button && (component.getStyle() & SWT.PUSH) != 0) {
gd = (GridData) component.getLayoutData();
gd.horizontalAlignment = GridData.FILL;
gd.widthHint = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ public void widgetDisposed(DisposeEvent e) {
if (fSite instanceof SDView) {
((SDView) fSite).resetProviders();
if (lm != null) {
lm.resetLoader(((SDView) fSite).getViewSite().getId());
lm.resetLoader(fSite.getViewSite().getId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public void setOverviewSize(int size) {
*/
public boolean isOverviewEnabled() {
if (fCornerControl instanceof Button) {
Object data = ((Button) fCornerControl).getData();
Object data = fCornerControl.getData();
// overview alreay
if (data instanceof Overview) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ protected GraphNode getCloserLeavingMessage(Lifeline lifeline, BaseMessage messa
int event = getMaxEventOccurrence();
if (message != null) {
if (message instanceof AsyncMessage) {
event = ((AsyncMessage) message).getStartOccurrence();
event = message.getStartOccurrence();
} else {
event = message.getEventOccurrence();
}
Expand Down Expand Up @@ -829,7 +829,7 @@ protected GraphNode getCloserEnteringMessage(Lifeline lifeline, BaseMessage mess
int event = getMaxEventOccurrence();
if (message != null) {
if (message instanceof AsyncMessage) {
event = ((AsyncMessage) message).getStartOccurrence();
event = message.getStartOccurrence();
} else {
event = message.getEventOccurrence();
}
Expand Down Expand Up @@ -864,8 +864,8 @@ protected int distanceFromEvent(GraphNode node, int event) {
if (node instanceof SyncMessage) {
distance = ((SyncMessage) node).getEventOccurrence() - event;
} else if (node instanceof AsyncMessage) {
int start = ((AsyncMessage) node).getStartOccurrence();
int end = ((AsyncMessage) node).getEndOccurrence();
int start = node.getStartOccurrence();
int end = node.getEndOccurrence();
if ((start - event) < (end - event)) {
distance = start - event;
} else {
Expand Down Expand Up @@ -993,7 +993,7 @@ public GraphNode getPrevLifelineMessage(Lifeline lifeline, BaseMessage startMess
int event = getMaxEventOccurrence();
if (startMessage != null) {
if (startMessage instanceof AsyncMessage) {
event = ((AsyncMessage) startMessage).getStartOccurrence();
event = startMessage.getStartOccurrence();
} else {
event = startMessage.getEventOccurrence();
}
Expand Down

0 comments on commit 871c450

Please sign in to comment.