Fixed bug 460421: Fix compiler problems from generified IAdaptable#getAdapter(..)
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java
index 35a5174..dff6eac 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 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
@@ -195,7 +195,7 @@
@Override
public void run() {
ITextEditor editor = (ITextEditor) fEditor;
- IRunToLineTarget adapter = (IRunToLineTarget) editor.getAdapter(IRunToLineTarget.class);
+ IRunToLineTarget adapter = editor.getAdapter(IRunToLineTarget.class);
assertNotNull("no run to line adapter", adapter); //$NON-NLS-1$
IDocumentProvider documentProvider = editor.getDocumentProvider();
assertNotNull("The document provider should not be null for: " + editor.getTitle(), documentProvider); //$NON-NLS-1$
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
index aacd417..aa7c49b 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 GEBIT Gesellschaft fuer EDV-Beratung
+ * Copyright (c) 2002, 2015 GEBIT Gesellschaft fuer EDV-Beratung
* und Informatik-Technologien mbH,
* Berlin, Duesseldorf, Frankfurt (Germany) and others.
* All rights reserved. This program and the accompanying materials
@@ -1902,7 +1902,7 @@
}
private String getIterationGestureMessage(String showMessage) {
- final IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence[] triggers = bindingSvc.getActiveBindingsFor(getContentAssistCommand());
String message;
if (triggers.length > 0) {
@@ -1914,7 +1914,7 @@
}
private ParameterizedCommand getContentAssistCommand() {
- final ICommandService commandSvc = (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+ final ICommandService commandSvc = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
final Command command = commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
ParameterizedCommand pCmd = new ParameterizedCommand(command, null);
return pCmd;
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/RunToLineAdapter.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/RunToLineAdapter.java
index 2d08423..9634e9a 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/RunToLineAdapter.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/RunToLineAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -70,7 +70,7 @@
IBreakpoint breakpoint = null;
Map<String, Object> attributes = getRunToLineAttributes();
- IFile file = (IFile) input.getAdapter(IFile.class);
+ IFile file = input.getAdapter(IFile.class);
if (file == null) {
errorMessage = AntEditorActionMessages.getString("RunToLineAdapter.2"); //$NON-NLS-1$
} else {
@@ -78,7 +78,7 @@
breakpoint.setPersisted(false);
errorMessage = AntEditorActionMessages.getString("RunToLineAdapter.3"); //$NON-NLS-1$
if (target instanceof IAdaptable) {
- IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable) target).getAdapter(IDebugTarget.class);
+ IDebugTarget debugTarget = ((IAdaptable) target).getAdapter(IDebugTarget.class);
if (debugTarget != null) {
RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint);
handler.run(new NullProgressMonitor());
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java
index f5a72b5..91fad53 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 GEBIT Gesellschaft fuer EDV-Beratung
+ * Copyright (c) 2002, 2015 GEBIT Gesellschaft fuer EDV-Beratung
* und Informatik-Technologien mbH,
* Berlin, Duesseldorf, Frankfurt (Germany) and others.
* All rights reserved. This program and the accompanying materials
@@ -36,9 +36,12 @@
import org.eclipse.ant.internal.ui.model.IAntModel;
import org.eclipse.ant.internal.ui.model.IAntModelListener;
import org.eclipse.ant.internal.ui.views.actions.AntOpenWithMenu;
+
import org.eclipse.core.resources.IFile;
+
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.ListenerList;
+
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
@@ -53,14 +56,18 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
+
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
+
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.ShowInContext;
+
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
/**
@@ -481,10 +488,11 @@
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class key) {
+ public <T> T getAdapter(Class<T> key) {
if (key == IShowInSource.class) {
- return this;
+ return (T) this;
}
return null;
}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
index a59cfca..1d9eb12 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -362,7 +362,7 @@
private AntStackFrame getFrame() {
IAdaptable adaptable = DebugUITools.getDebugContext();
if (adaptable != null) {
- return (AntStackFrame) adaptable.getAdapter(AntStackFrame.class);
+ return adaptable.getAdapter(AntStackFrame.class);
}
return null;
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
index 79af08c..d9e4926 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -638,7 +638,7 @@
if (resource.getType() == IResource.FILE) {
file = (IFile) resource;
} else {
- file = (IFile) resource.getAdapter(IFile.class);
+ file = resource.getAdapter(IFile.class);
}
if (file != null) {
IContentType fileType = IDE.getContentType(file);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
index bd9654f..caf0ac2 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2013 Richard Hoefter and others.
+ * Copyright (c) 2004, 2015 Richard Hoefter 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
@@ -94,7 +94,7 @@
if (selection instanceof IStructuredSelection) {
for (Iterator<IAdaptable> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext();) {
IAdaptable adaptable = iter.next();
- return (IResource) adaptable.getAdapter(IResource.class);
+ return adaptable.getAdapter(IResource.class);
}
}
return null;
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java
index 09b8d6a..c7bcd19 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -85,7 +85,7 @@
launch((AntElementNode) object, mode);
return;
}
- IResource resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) object).getAdapter(IResource.class);
if (resource != null) {
if (!(AntUtil.isKnownAntFile(resource))) {
if (!AntUtil.isKnownBuildfileName(resource.getName())) {
@@ -147,7 +147,7 @@
IEditorPart editor = page.getActiveEditor();
if (editor != null) {
IEditorInput editorInput = editor.getEditorInput();
- ILocationProvider locationProvider = (ILocationProvider) editorInput.getAdapter(ILocationProvider.class);
+ ILocationProvider locationProvider = editorInput.getAdapter(ILocationProvider.class);
if (locationProvider != null) {
filePath = locationProvider.getPath(editorInput);
if (filePath != null) {
@@ -485,13 +485,13 @@
@Override
public void launch(IEditorPart editor, String mode) {
IEditorInput input = editor.getEditorInput();
- IFile file = (IFile) input.getAdapter(IFile.class);
+ IFile file = input.getAdapter(IFile.class);
IPath filepath = null;
if (file != null) {
filepath = file.getFullPath();
}
if (filepath == null) {
- ILocationProvider locationProvider = (ILocationProvider) input.getAdapter(ILocationProvider.class);
+ ILocationProvider locationProvider = input.getAdapter(ILocationProvider.class);
if (locationProvider != null) {
filepath = locationProvider.getPath(input);
}
@@ -554,7 +554,7 @@
// the user for which config to run and specify the correct target
return new ILaunchConfiguration[0];
}
- IResource resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) object).getAdapter(IResource.class);
if (resource != null) {
if (!(AntUtil.isKnownAntFile(resource))) {
if (!AntUtil.isKnownBuildfileName(resource.getName())) {
@@ -585,13 +585,13 @@
@Override
public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editor) {
IEditorInput input = editor.getEditorInput();
- IFile file = (IFile) input.getAdapter(IFile.class);
+ IFile file = input.getAdapter(IFile.class);
IPath filepath = null;
if (file != null) {
filepath = file.getLocation();
}
if (filepath == null) {
- ILocationProvider locationProvider = (ILocationProvider) input.getAdapter(ILocationProvider.class);
+ ILocationProvider locationProvider = input.getAdapter(ILocationProvider.class);
if (locationProvider != null) {
filepath = locationProvider.getPath(input);
}
@@ -615,7 +615,7 @@
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object object = structuredSelection.getFirstElement();
if (object instanceof IAdaptable) {
- IResource resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
+ IResource resource = ((IAdaptable) object).getAdapter(IResource.class);
if (resource != null) {
if (!(AntUtil.isKnownAntFile(resource))) {
if (AntUtil.isKnownBuildfileName(resource.getName())) {
@@ -641,6 +641,6 @@
@Override
public IResource getLaunchableResource(IEditorPart editor) {
IEditorInput input = editor.getEditorInput();
- return (IFile) input.getAdapter(IFile.class);
+ return input.getAdapter(IFile.class);
}
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementAdapterFactory.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementAdapterFactory.java
index a79837e..907dc0c 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementAdapterFactory.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2015 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
@@ -11,6 +11,7 @@
package org.eclipse.ant.internal.ui.model;
import org.eclipse.core.resources.IResource;
+
import org.eclipse.core.runtime.IAdapterFactory;
/**
@@ -23,12 +24,13 @@
*
* @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 (adaptableObject instanceof AntElementNode) {
AntElementNode node = (AntElementNode) adaptableObject;
if (IResource.class.equals(adapterType)) {
- return node.getIFile();
+ return (T) node.getIFile();
}
}
return null;
@@ -40,7 +42,7 @@
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return new Class[] { IResource.class };
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java
index 04b7aee..b4d0a7d 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 GEBIT Gesellschaft fuer EDV-Beratung
+ * Copyright (c) 2002, 2015 GEBIT Gesellschaft fuer EDV-Beratung
* und Informatik-Technologien mbH,
* Berlin, Duesseldorf, Frankfurt (Germany) and others.
* All rights reserved. This program and the accompanying materials
@@ -595,7 +595,7 @@
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return Platform.getAdapterManager().getAdapter(this, adapter);
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java
index 924b209..ef5962c 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -27,7 +27,7 @@
if (fEditorInput instanceof IFileEditorInput) {
return ((IFileEditorInput) fEditorInput).getFile().getLocation();
}
- ILocationProvider locationProvider = (ILocationProvider) fEditorInput.getAdapter(ILocationProvider.class);
+ ILocationProvider locationProvider = fEditorInput.getAdapter(ILocationProvider.class);
if (locationProvider != null) {
return locationProvider.getPath(fEditorInput);
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java
index 1af2a6f..dca5118 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -17,7 +17,9 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
+
import org.eclipse.jface.resource.ImageDescriptor;
+
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.IWorkbenchAdapter;
@@ -54,10 +56,11 @@
/**
* Returns the adapter
*/
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IWorkbenchAdapter.class) {
- return this;
+ return (T) this;
}
// defer to the platform
return Platform.getAdapterManager().getAdapter(this, adapter);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesDialog.java
index 83c0309..91b4d23 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesDialog.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -313,7 +313,7 @@
if (adaptable instanceof IResource) {
resource = (IResource) adaptable;
} else {
- resource = (IResource) adaptable.getAdapter(IResource.class);
+ resource = adaptable.getAdapter(IResource.class);
}
if (resource != null) {
searchScopes.add(resource);