mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Generify o.e.cdt.debug.core.
Fix warnings about adapters and listener lists not being generified. Change-Id: If5e54e6df452884947f32a31ef9c0c53677b88c8 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
9b4dba0458
commit
240d68cac5
8 changed files with 50 additions and 81 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2016 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -26,24 +26,19 @@ import org.eclipse.debug.core.commands.IRestartHandler;
|
|||
public class CCommandAdapterFactory implements IAdapterFactory {
|
||||
private static IRestartHandler fgRestartCommand = new RestartCommand();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||
if (IRestartHandler.class.equals(adapterType)) {
|
||||
if (adaptableObject instanceof IRestart) {
|
||||
return fgRestartCommand;
|
||||
return (T) fgRestartCommand;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||
*/
|
||||
@Override
|
||||
public Class[] getAdapterList() {
|
||||
public Class<?>[] getAdapterList() {
|
||||
return new Class[] {
|
||||
IRestartHandler.class
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2011 Nokia and others.
|
||||
* Copyright (c) 2008, 2016 Nokia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -156,14 +156,14 @@ public class Executable extends PlatformObject {
|
|||
return name;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (adapter.equals(IResource.class))
|
||||
if (getResource() != null)
|
||||
return getResource();
|
||||
return (T) getResource();
|
||||
else
|
||||
return this.getProject();
|
||||
return (T) this.getProject();
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems and others.
|
||||
* Copyright (c) 2012, 2016 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -19,10 +19,9 @@ import org.eclipse.debug.core.model.IDebugModelProvider;
|
|||
* Debug model provider returns additional model ID to use with
|
||||
* GDB event breakpoints.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class DebugModelProvider implements IDebugModelProvider, IAdapterFactory {
|
||||
|
||||
private final static Class[] ADAPTER_LIST = new Class[] { IDebugModelProvider.class };
|
||||
private final static Class<?>[] ADAPTER_LIST = new Class[] { IDebugModelProvider.class };
|
||||
private final static String GDB_MODEL_ID = "org.eclipse.cdt.gdb"; //$NON-NLS-1$
|
||||
private final static String[] MODEL_IDS = new String[] { CDIDebugModel.getPluginIdentifier(), GDB_MODEL_ID };
|
||||
|
||||
|
@ -31,16 +30,17 @@ public class DebugModelProvider implements IDebugModelProvider, IAdapterFactory
|
|||
return MODEL_IDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||
if ( adaptableObject instanceof ICDebugElement && IDebugModelProvider.class.equals(adapterType) ) {
|
||||
return this;
|
||||
return (T) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getAdapterList() {
|
||||
public Class<?>[] getAdapterList() {
|
||||
return ADAPTER_LIST;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 ARM Limited and others.
|
||||
* Copyright (c) 2008, 2016 ARM Limited and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -20,56 +20,44 @@ import org.eclipse.core.runtime.ListenerList;
|
|||
|
||||
public class DisassemblyContextService implements IDisassemblyContextService {
|
||||
|
||||
private ListenerList fListeners;
|
||||
private ListenerList<IDisassemblyContextListener> fListeners;
|
||||
private Set<Object> fContexts;
|
||||
|
||||
public DisassemblyContextService() {
|
||||
fContexts = new CopyOnWriteArraySet<Object>();
|
||||
fListeners = new ListenerList();
|
||||
fListeners = new ListenerList<>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#addDisassemblyContextListener(org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener)
|
||||
*/
|
||||
@Override
|
||||
public void addDisassemblyContextListener( IDisassemblyContextListener listener ) {
|
||||
fListeners.add( listener );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#removeDisassemblyContextListener(org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeDisassemblyContextListener( IDisassemblyContextListener listener ) {
|
||||
fListeners.remove( listener );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#register(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void register( Object context ) {
|
||||
fContexts.add( context );
|
||||
for( Object listener : fListeners.getListeners() ) {
|
||||
((IDisassemblyContextListener)listener).contextAdded( context );
|
||||
for( IDisassemblyContextListener listener : fListeners) {
|
||||
listener.contextAdded( context );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#unregister(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void unregister( Object context ) {
|
||||
fContexts.remove( context );
|
||||
for( Object listener : fListeners.getListeners() ) {
|
||||
((IDisassemblyContextListener)listener).contextRemoved( context );
|
||||
for( IDisassemblyContextListener listener : fListeners) {
|
||||
listener.contextRemoved( context );
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for( Object context : fContexts ) {
|
||||
for( Object listener : fListeners.getListeners() ) {
|
||||
((IDisassemblyContextListener)listener).contextRemoved( context );
|
||||
for( IDisassemblyContextListener listener : fListeners) {
|
||||
listener.contextRemoved( context );
|
||||
}
|
||||
}
|
||||
fListeners.clear();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2012 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -107,17 +107,15 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (adapter.equals(ICSourceLocation.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(CDirectorySourceLocation.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(IPath.class))
|
||||
return getDirectory();
|
||||
return (T) getDirectory();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2012 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -98,17 +98,15 @@ public class CProjectSourceLocation implements IProjectSourceLocation {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (adapter.equals(ICSourceLocation.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(CProjectSourceLocation.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(IProject.class))
|
||||
return getProject();
|
||||
return (T) getProject();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2016 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -83,20 +83,17 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato
|
|||
return (getCSourceLocator() != null) ? getCSourceLocator().contains(resource) : false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
||||
public <T> T getAdapter(Class<T> adapter) {
|
||||
if (adapter.equals(CSourceManager.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(ICSourceLocator.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(IPersistableSourceLocator.class))
|
||||
return this;
|
||||
return (T) this;
|
||||
if (adapter.equals(IResourceChangeListener.class) && fSourceLocator instanceof IResourceChangeListener)
|
||||
return fSourceLocator;
|
||||
return (T) fSourceLocator;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2012 Freescale Semiconductor and others.
|
||||
* Copyright (c) 2010, 2016 Freescale Semiconductor and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -19,26 +19,19 @@ import org.eclipse.core.runtime.IAdapterFactory;
|
|||
*/
|
||||
public class CSourceFinderFactory implements IAdapterFactory {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||
if (adaptableObject instanceof IBinary) {
|
||||
if (adapterType.equals(ISourceFinder.class)) {
|
||||
return new CSourceFinder((IBinary)adaptableObject);
|
||||
return (T) new CSourceFinder((IBinary)adaptableObject);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class[] getAdapterList() {
|
||||
public Class<?>[] getAdapterList() {
|
||||
return new Class[] { ISourceFinder.class };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue