1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

Move to new getAdapter() signature using generics

Change-Id: If51cc778c1b7e7dfea7a6fb3b7f39acea56aa330
Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc Khouzam 2015-04-15 13:54:53 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 9cc312e1fe
commit ecf21ca882
16 changed files with 99 additions and 106 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2014 Nokia and others. * Copyright (c) 2010, 2015 Nokia and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -40,13 +40,13 @@ import com.ibm.icu.text.MessageFormat;
public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
@Override @Override
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, Class adapterType) { public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType.equals(ICSourceNotFoundDescription.class) && if (adapterType.equals(ICSourceNotFoundDescription.class) &&
adaptableObject instanceof IFrameDMContext) adaptableObject instanceof IFrameDMContext)
{ {
final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject; final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject;
return new ICSourceNotFoundDescription() { return (T)new ICSourceNotFoundDescription() {
@Override @Override
public String getDescription() { public String getDescription() {
@ -84,8 +84,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
} }
@Override @Override
@SuppressWarnings("rawtypes") public Class<?>[] getAdapterList() {
public Class[] getAdapterList() {
return new Class[] { ICSourceNotFoundDescription.class }; return new Class[] { ICSourceNotFoundDescription.class };
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. and others. * Copyright (c) 2010, 2015 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -28,28 +28,27 @@ public class DebugTextHoverAdapterFactory implements IAdapterFactory {
private static final Class<?>[] TYPES = { ICEditorTextHover.class }; private static final Class<?>[] TYPES = { ICEditorTextHover.class };
private static final Object fDebugTextHover= new DsfDebugTextHover(); private static final Object fDebugTextHover= new DsfDebugTextHover();
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof IDMVMContext) { if (adaptableObject instanceof IDMVMContext) {
IDMContext dmc = ((IDMVMContext) adaptableObject).getDMContext(); IDMContext dmc = ((IDMVMContext) adaptableObject).getDMContext();
// try session specific hover // try session specific hover
Object sessionHover = dmc.getAdapter(adapterType); T sessionHover = dmc.getAdapter(adapterType);
if (sessionHover != null) { if (sessionHover != null) {
return sessionHover; return sessionHover;
} }
// use default // use default
IFrameDMContext frameDmc = DMContexts.getAncestorOfType(dmc, IFrameDMContext.class); IFrameDMContext frameDmc = DMContexts.getAncestorOfType(dmc, IFrameDMContext.class);
if (frameDmc != null) { if (frameDmc != null) {
return fDebugTextHover; return (T)fDebugTextHover;
} }
} }
return null; return null;
} }
@Override @Override
@SuppressWarnings("rawtypes") public Class<?>[] getAdapterList() {
public Class[] getAdapterList() {
return TYPES; return TYPES;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Wind River Systems and others. * Copyright (c) 2009, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -43,17 +43,17 @@ public class SuspendResumeAdapterFactory implements IAdapterFactory {
fResumeAtLine = new ResumeAtLine(execCtx); fResumeAtLine = new ResumeAtLine(execCtx);
} }
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) {
if (adapter.isInstance(fRunToLine)) { if (adapter.isInstance(fRunToLine)) {
return fRunToLine; return (T)fRunToLine;
} }
if (adapter.isInstance(fMoveToLine)) { if (adapter.isInstance(fMoveToLine)) {
return fMoveToLine; return (T)fMoveToLine;
} }
if (adapter.isInstance(fResumeAtLine)) { if (adapter.isInstance(fResumeAtLine)) {
return fResumeAtLine; return (T)fResumeAtLine;
} }
return null; return null;
} }
@ -73,9 +73,9 @@ public class SuspendResumeAdapterFactory implements IAdapterFactory {
public void suspend() throws DebugException {} public void suspend() throws DebugException {}
} }
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (ISuspendResume.class.equals(adapterType)) { if (ISuspendResume.class.equals(adapterType)) {
if (adaptableObject instanceof IDMVMContext) { if (adaptableObject instanceof IDMVMContext) {
IExecutionDMContext execDmc = DMContexts.getAncestorOfType( IExecutionDMContext execDmc = DMContexts.getAncestorOfType(
@ -84,7 +84,7 @@ public class SuspendResumeAdapterFactory implements IAdapterFactory {
// It only makes sense to RunToLine, MoveToLine or // It only makes sense to RunToLine, MoveToLine or
// ResumeAtLine if we are dealing with a thread, not a container // ResumeAtLine if we are dealing with a thread, not a container
if (execDmc != null && !(execDmc instanceof IContainerDMContext)) { if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
return new SuspendResume(execDmc); return (T)new SuspendResume(execDmc);
} }
} }
} }
@ -92,8 +92,7 @@ public class SuspendResumeAdapterFactory implements IAdapterFactory {
} }
@Override @Override
@SuppressWarnings("rawtypes") public Class<?>[] getAdapterList() {
public Class[] getAdapterList() {
return new Class[] { ISuspendResume.class }; return new Class[] { ISuspendResume.class };
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Ericsson and others. * Copyright (c) 2010, 2015 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,16 +26,16 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/ */
@Override @Override
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, Class adapterType) { public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType == IRunToLineTarget.class) { if (adapterType == IRunToLineTarget.class) {
return new DisassemblyRunToLineAdapter(); return (T)new DisassemblyRunToLineAdapter();
} }
if (adapterType == IMoveToLineTarget.class) { if (adapterType == IMoveToLineTarget.class) {
return new DisassemblyMoveToLineAdapter(); return (T)new DisassemblyMoveToLineAdapter();
} }
if (adapterType == IResumeAtLineTarget.class) { if (adapterType == IResumeAtLineTarget.class) {
return new DisassemblyResumeAtLineAdapter(); return (T)new DisassemblyResumeAtLineAdapter();
} }
return null; return null;
} }
@ -44,8 +44,7 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/ */
@Override @Override
@SuppressWarnings("rawtypes") public Class<?>[] getAdapterList() {
public Class[] getAdapterList() {
return new Class[]{ IRunToLineTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class }; return new Class[]{ IRunToLineTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class };
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Freescale Semiconductor, Inc. and others. * Copyright (c) 2010, 2015 Freescale Semiconductor, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -24,8 +24,8 @@ public class DisassemblyBackendDsfFactory implements IAdapterFactory {
private static final Class<?>[] ADAPTERS = { IDisassemblyBackend.class }; private static final Class<?>[] ADAPTERS = { IDisassemblyBackend.class };
@Override @Override
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, Class adapterType) { public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (IDisassemblyBackend.class.equals(adapterType)) { if (IDisassemblyBackend.class.equals(adapterType)) {
if (adaptableObject instanceof IAdaptable && DisassemblyBackendDsf.supportsDebugContext_((IAdaptable)adaptableObject)) { if (adaptableObject instanceof IAdaptable && DisassemblyBackendDsf.supportsDebugContext_((IAdaptable)adaptableObject)) {
String sessionId = ((IDMVMContext) adaptableObject).getDMContext().getSessionId(); String sessionId = ((IDMVMContext) adaptableObject).getDMContext().getSessionId();
@ -33,20 +33,19 @@ public class DisassemblyBackendDsfFactory implements IAdapterFactory {
if (session.isActive()) { if (session.isActive()) {
IAdapterFactory factory = (IAdapterFactory) session.getModelAdapter(IAdapterFactory.class); IAdapterFactory factory = (IAdapterFactory) session.getModelAdapter(IAdapterFactory.class);
if (factory != null) { if (factory != null) {
Object adapter = factory.getAdapter(adaptableObject, adapterType); T adapter = factory.getAdapter(adaptableObject, adapterType);
if (adapter != null) if (adapter != null)
return adapter; return adapter;
} }
} }
return new DisassemblyBackendDsf(); return (T)new DisassemblyBackendDsf();
} }
} }
return null; return null;
} }
@Override @Override
@SuppressWarnings("rawtypes") public Class<?>[] getAdapterList() {
public Class[] getAdapterList() {
return ADAPTERS; return ADAPTERS;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2014 Wind River Systems and others. * Copyright (c) 2007, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -537,26 +537,26 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
/* /*
* @see IAdaptable#getAdapter(java.lang.Class) * @see IAdaptable#getAdapter(java.lang.Class)
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(Class required) { public <T> T getAdapter(Class<T> required) {
if (IVerticalRulerInfo.class.equals(required)) { if (IVerticalRulerInfo.class.equals(required)) {
if (fVerticalRuler != null) { if (fVerticalRuler != null) {
return fVerticalRuler; return (T)fVerticalRuler;
} }
} else if (IDisassemblyPart.class.equals(required)) { } else if (IDisassemblyPart.class.equals(required)) {
return this; return (T)this;
} else if (IFindReplaceTarget.class.equals(required)) { } else if (IFindReplaceTarget.class.equals(required)) {
if (fFindReplaceTarget == null) { if (fFindReplaceTarget == null) {
fFindReplaceTarget = (fViewer == null ? null : fViewer.getFindReplaceTarget()); fFindReplaceTarget = (fViewer == null ? null : fViewer.getFindReplaceTarget());
} }
return fFindReplaceTarget; return (T)fFindReplaceTarget;
} else if (ITextOperationTarget.class.equals(required)) { } else if (ITextOperationTarget.class.equals(required)) {
return (fViewer == null ? null : fViewer.getTextOperationTarget()); return (fViewer == null ? null : (T)fViewer.getTextOperationTarget());
} else if (Control.class.equals(required)) { } else if (Control.class.equals(required)) {
return fViewer != null ? fViewer.getTextWidget() : null; return fViewer != null ? (T)fViewer.getTextWidget() : null;
} else if (IGotoMarker.class.equals(required)) { } else if (IGotoMarker.class.equals(required)) {
return new IGotoMarker() { return (T)new IGotoMarker() {
@Override @Override
public void gotoMarker(IMarker marker) { public void gotoMarker(IMarker marker) {
DisassemblyPart.this.gotoMarker(marker); DisassemblyPart.this.gotoMarker(marker);
@ -564,7 +564,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} else if (IColumnSupport.class.equals(required)) { } else if (IColumnSupport.class.equals(required)) {
if (fColumnSupport == null) if (fColumnSupport == null)
fColumnSupport= createColumnSupport(); fColumnSupport= createColumnSupport();
return fColumnSupport; return (T)fColumnSupport;
} }
return super.getAdapter(required); return super.getAdapter(required);
@ -577,7 +577,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
*/ */
private void addRulerContributionActions(IMenuManager menu) { private void addRulerContributionActions(IMenuManager menu) {
// store directly in generic editor preferences // store directly in generic editor preferences
final IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class); final IColumnSupport support= getAdapter(IColumnSupport.class);
IPreferenceStore store= DsfUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store= DsfUIPlugin.getDefault().getPreferenceStore();
final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, PREFERENCE_RULER_CONTRIBUTIONS); final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, PREFERENCE_RULER_CONTRIBUTIONS);
List<RulerColumnDescriptor> descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors(); List<RulerColumnDescriptor> descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors();
@ -608,7 +608,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
* @param ruler the composite ruler to add contributions to * @param ruler the composite ruler to add contributions to
*/ */
protected void updateContributedRulerColumns(CompositeRuler ruler) { protected void updateContributedRulerColumns(CompositeRuler ruler) {
IColumnSupport support= (IColumnSupport)getAdapter(IColumnSupport.class); IColumnSupport support= getAdapter(IColumnSupport.class);
if (support == null) if (support == null)
return; return;
@ -689,7 +689,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fPCHistorySizeMax = store.getInt(property); fPCHistorySizeMax = store.getInt(property);
} else if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) { } else if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue()); String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class); IColumnSupport support= getAdapter(IColumnSupport.class);
for (int i= 0; i < difference.length; i++) { for (int i= 0; i < difference.length; i++) {
RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]); RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
if (desc != null && support.isColumnSupported(desc)) { if (desc != null && support.isColumnSupported(desc)) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Wind River Systems and others. * Copyright (c) 2007, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -108,8 +108,7 @@ abstract public class StorageEditorInput implements IStorageEditorInput {
} }
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) {
return null; return null;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 IBM Corporation and others. * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -724,13 +724,13 @@ public class NumberFormatDetailPane implements IDetailPane2, IAdaptable, IProper
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
@Override @Override
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
public Object getAdapter(Class required) { public <T> T getAdapter(Class<T> required) {
if (IFindReplaceTarget.class.equals(required)) { if (IFindReplaceTarget.class.equals(required)) {
return fTextViewer.getFindReplaceTarget(); return (T)fTextViewer.getFindReplaceTarget();
} }
if (ITextViewer.class.equals(required)) { if (ITextViewer.class.equals(required)) {
return fTextViewer; return (T)fTextViewer;
} }
return null; return null;
} }

View file

@ -1,5 +1,5 @@
/***************************************************************** /*****************************************************************
* Copyright (c) 2011, 2014 Wind River Systems and others. * Copyright (c) 2011, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -138,10 +138,11 @@ public class SimpleMapPersistable<V> implements IPersistableElement, IAdaptable
return SimpleMapPersistableFactory.getFactoryId(); return SimpleMapPersistableFactory.getFactoryId();
} }
@SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { public <T> T getAdapter(Class<T> adapter) {
if (adapter.isInstance(this)) { if (adapter.isInstance(this)) {
return this; return (T)this;
} }
return null; return null;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Wind River Systems and others. * Copyright (c) 2008, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -29,11 +29,11 @@ public class BreakpointVMContext extends AbstractVMContext {
return fBreakpoint; return fBreakpoint;
} }
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) {
if (adapter.isInstance(fBreakpoint)) { if (adapter.isInstance(fBreakpoint)) {
return fBreakpoint; return (T)fBreakpoint;
} }
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -73,8 +73,7 @@ public class ExpressionManagerVMNode extends AbstractVMNode
} }
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) {
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2015 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -54,16 +54,16 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa
public IDMContext getDMContext() { public IDMContext getDMContext() {
return fDmc; return fDmc;
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(Class adapter) { public <T> T getAdapter(Class<T> adapter) {
Object superAdapter = super.getAdapter(adapter); T superAdapter = super.getAdapter(adapter);
if (superAdapter != null) { if (superAdapter != null) {
return superAdapter; return superAdapter;
} else { } else {
// Delegate to the Data Model to find the context. // Delegate to the Data Model to find the context.
if (adapter.isInstance(fDmc)) { if (adapter.isInstance(fDmc)) {
return fDmc; return (T)fDmc;
} else { } else {
return fDmc.getAdapter(adapter); return fDmc.getAdapter(adapter);
} }
@ -121,9 +121,8 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa
public String getModelIdentifier() { public String getModelIdentifier() {
return null; return null;
} }
@SuppressWarnings("rawtypes")
@Override @Override
public Object getAdapter(Class adapter) { public <T> T getAdapter(Class<T> adapter) {
return null; return null;
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 IBM Corporation and others. * Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -181,11 +181,11 @@ public class ModuleDetailPane extends ModulesAbstractDetailPane implements IAdap
return false; return false;
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(Class adapter) { public <T> T getAdapter(Class<T> adapter) {
if (ITextViewer.class.equals(adapter)) { if (ITextViewer.class.equals(adapter)) {
return fSourceViewer; return (T)fSourceViewer;
} }
return null; return null;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2014 Wind River Systems and others. * Copyright (c) 2006, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -236,16 +236,16 @@ public class RegisterVMProvider extends AbstractElementVMProvider
* The IAdaptable implementation. If the adapter is the DM context, * The IAdaptable implementation. If the adapter is the DM context,
* return the context, otherwise delegate to IDMContext.getAdapter(). * return the context, otherwise delegate to IDMContext.getAdapter().
*/ */
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) { T superAdapter = super.getAdapter(adapter);
Object superAdapter = super.getAdapter(adapter);
if (superAdapter != null) { if (superAdapter != null) {
return superAdapter; return superAdapter;
} else { } else {
// Delegate to the Data Model to find the context. // Delegate to the Data Model to find the context.
if (adapter.isInstance(fDMContext)) { if (adapter.isInstance(fDMContext)) {
return fDMContext; return (T)fDMContext;
} else { } else {
return fDMContext.getAdapter(adapter); return fDMContext.getAdapter(adapter);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -41,23 +41,23 @@ abstract public class AbstractVMContext implements IVMContext {
@Override @Override
public IVMNode getVMNode() { return fNode; } public IVMNode getVMNode() { return fNode; }
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) {
// If the context implements the given adapter directly, it always takes // If the context implements the given adapter directly, it always takes
// precedence. // precedence.
if (adapter.isInstance(this)) { if (adapter.isInstance(this)) {
return this; return (T)this;
} }
IVMProvider vmProvider = getVMNode().getVMProvider(); IVMProvider vmProvider = getVMNode().getVMProvider();
IVMAdapter vmAdapter = vmProvider.getVMAdapter(); IVMAdapter vmAdapter = vmProvider.getVMAdapter();
if (adapter.isInstance(vmAdapter)) { if (adapter.isInstance(vmAdapter)) {
return vmAdapter; return (T)vmAdapter;
} else if (adapter.isInstance(vmProvider)) { } else if (adapter.isInstance(vmProvider)) {
return vmProvider; return (T)vmProvider;
} else if (adapter.isInstance(getVMNode())) { } else if (adapter.isInstance(getVMNode())) {
return getVMNode(); return (T)getVMNode();
} }
return Platform.getAdapterManager().getAdapter(this, adapter); return Platform.getAdapterManager().getAdapter(this, adapter);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2015 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -66,16 +66,16 @@ abstract public class AbstractDMVMNode extends AbstractVMNode implements IVMNode
* The IAdaptable implementation. If the adapter is the DM context, * The IAdaptable implementation. If the adapter is the DM context,
* return the context, otherwise delegate to IDMContext.getAdapter(). * return the context, otherwise delegate to IDMContext.getAdapter().
*/ */
@SuppressWarnings("unchecked")
@Override @Override
@SuppressWarnings("rawtypes") public <T> T getAdapter(Class<T> adapter) {
public Object getAdapter(Class adapter) { T superAdapter = super.getAdapter(adapter);
Object superAdapter = super.getAdapter(adapter);
if (superAdapter != null) { if (superAdapter != null) {
return superAdapter; return superAdapter;
} else { } else {
// Delegate to the Data Model to find the context. // Delegate to the Data Model to find the context.
if (adapter.isInstance(fDmc)) { if (adapter.isInstance(fDmc)) {
return fDmc; return (T)fDmc;
} else { } else {
return fDmc.getAdapter(adapter); return fDmc.getAdapter(adapter);
} }