Generify getAdapter implementation and calls.
All instances found are changed.
Change-Id: Iff227ec11cc2fe2885e7ba7006df481ed2f108f5
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java
index 808fae7..20c2f71 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/AbstractProblemReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -20,7 +20,8 @@
public abstract class AbstractProblemReporter implements IProblemReporter,
IAdaptable {
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCollector.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCollector.java
index c4c16fe..21ce8bd 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCollector.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -51,11 +51,12 @@
return problems.isEmpty();
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (ITaskReporter.class.equals(adapter)
|| IProblemReporter.class.equals(adapter)) {
- return this;
+ return (T) this;
}
return super.getAdapter(adapter);
}
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java
index ffe95cf..6d54c9e 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/problem/ProblemReporterProxy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -34,7 +34,8 @@
}
}
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
if (original != null && original instanceof IAdaptable) {
return ((IAdaptable) original).getAdapter(adapter);
}
diff --git a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/task/DelegatingTaskReporter.java b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/task/DelegatingTaskReporter.java
index ac7b2f6..8f86cde 100644
--- a/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/task/DelegatingTaskReporter.java
+++ b/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/task/DelegatingTaskReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
+ * Copyright (c) 2010, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -35,7 +35,7 @@
charStart + locationOffset, charEnd + locationOffset);
}
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LazyEnvironment.java b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LazyEnvironment.java
index b2867c7..d9c64ba 100644
--- a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LazyEnvironment.java
+++ b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LazyEnvironment.java
@@ -136,7 +136,7 @@
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
initialize();
return environment != null ? environment.getAdapter(adapter) : null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LocalEnvironment.java b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LocalEnvironment.java
index 39213d0..9470ede 100644
--- a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LocalEnvironment.java
+++ b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/internal/environment/LocalEnvironment.java
@@ -93,10 +93,11 @@
return EnvironmentPathUtils.getLocalPath(path).toOSString();
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager()
- .loadAdapter(this, adapter.getName());
+ public <T> T getAdapter(Class<T> adapter) {
+ return (T) Platform.getAdapterManager().loadAdapter(this,
+ adapter.getName());
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractExternalSourceModule.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractExternalSourceModule.java
index 2cc6810..202329d 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractExternalSourceModule.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractExternalSourceModule.java
@@ -79,10 +79,11 @@
// external, do nothing
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IStorage.class) {
- return this;
+ return (T) this;
}
return super.getAdapter(adapter);
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ResourceChangeToNonScriptDelta.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ResourceChangeToNonScriptDelta.java
index 7d775d8..5013c78 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ResourceChangeToNonScriptDelta.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ResourceChangeToNonScriptDelta.java
@@ -114,7 +114,7 @@
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ExternalModuleBuildContext.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ExternalModuleBuildContext.java
index e5bf512..0975bf2 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ExternalModuleBuildContext.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/ExternalModuleBuildContext.java
@@ -61,7 +61,7 @@
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/AdaptUtils.java b/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/AdaptUtils.java
index 12d2961..b5b39bc 100644
--- a/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/AdaptUtils.java
+++ b/core/plugins/org.eclipse.dltk.core/utils/org/eclipse/dltk/utils/AdaptUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -44,18 +44,18 @@
}
if (anElement instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) anElement;
- Object result = adaptable.getAdapter(anAdapterType);
+ T result = adaptable.getAdapter(anAdapterType);
if (result != null) {
// Sanity-check
Assert.isTrue(anAdapterType.isInstance(result));
- return (T) result;
+ return result;
}
}
if (!(anElement instanceof PlatformObject)) {
- Object result = Platform.getAdapterManager().getAdapter(anElement,
+ T result = Platform.getAdapterManager().getAdapter(anElement,
anAdapterType);
if (result != null) {
- return (T) result;
+ return result;
}
}
return null;
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
index f5deee2..749e37f 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
@@ -646,10 +646,9 @@
}
}
- @SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> key) {
- Object adpater = super.getAdapter(key);
+ T adpater = super.getAdapter(key);
if (adpater == null) {
IConsole console = getConsole();
if (console != null) {
@@ -662,13 +661,13 @@
IConsolePageParticipant participant = (IConsolePageParticipant) participants[i];
adpater = participant.getAdapter(key);
if (adpater != null) {
- return (T) adpater;
+ return adpater;
}
}
}
}
}
- return (T) adpater;
+ return adpater;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugElement.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugElement.java
index 5d76cb1..7f809e4 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugElement.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugElement.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.debug.core.model;
@@ -25,8 +24,8 @@
import org.eclipse.dltk.debug.core.model.IScriptDebugElement;
import org.eclipse.dltk.debug.core.model.IScriptDebugTarget;
-public abstract class ScriptDebugElement extends PlatformObject implements
- IScriptDebugElement {
+public abstract class ScriptDebugElement extends PlatformObject
+ implements IScriptDebugElement {
public IScriptDebugTarget getScriptDebugTarget() {
return (IScriptDebugTarget) getDebugTarget();
@@ -40,9 +39,11 @@
return getDebugTarget().getModelIdentifier();
}
- public Object getAdapter(Class adapter) {
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IDebugElement.class) {
- return this;
+ return (T) this;
}
/*
@@ -52,46 +53,47 @@
*/
if (adapter == IDebugTarget.class) {
- return getDebugTarget();
+ return (T) getDebugTarget();
}
if (adapter == ITerminate.class) {
- return getDebugTarget();
+ return (T) getDebugTarget();
}
if (adapter == IScriptDebugTarget.class) {
- return getScriptDebugTarget();
+ return (T) getScriptDebugTarget();
}
if (adapter == ILaunch.class) {
- return getLaunch();
+ return (T) getLaunch();
}
return super.getAdapter(adapter);
}
protected void abort(String message, Throwable e) throws DebugException {
- throw new DebugException(new Status(IStatus.ERROR,
- DLTKDebugPlugin.PLUGIN_ID, DebugPlugin.INTERNAL_ERROR, message,
- e));
+ throw new DebugException(
+ new Status(IStatus.ERROR, DLTKDebugPlugin.PLUGIN_ID,
+ DebugPlugin.INTERNAL_ERROR, message, e));
}
protected DebugException makeNotSupported(String message, Throwable e)
throws DebugException {
- return new DebugException(new Status(IStatus.ERROR,
- DLTKDebugPlugin.PLUGIN_ID, DebugException.NOT_SUPPORTED,
- message, e));
+ return new DebugException(
+ new Status(IStatus.ERROR, DLTKDebugPlugin.PLUGIN_ID,
+ DebugException.NOT_SUPPORTED, message, e));
}
- protected DebugException wrapDbgpException(String message, DbgpException e) {
- return new DebugException(new Status(IStatus.ERROR, DebugPlugin
- .getUniqueIdentifier(), DebugException.INTERNAL_ERROR, message,
- e));
+ protected DebugException wrapDbgpException(String message,
+ DbgpException e) {
+ return new DebugException(
+ new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.INTERNAL_ERROR, message, e));
}
protected DebugException wrapIOException(String message, IOException e) {
- return new DebugException(new Status(IStatus.ERROR, DebugPlugin
- .getUniqueIdentifier(), DebugException.INTERNAL_ERROR, message,
- e));
+ return new DebugException(
+ new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
+ DebugException.INTERNAL_ERROR, message, e));
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValue.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValue.java
index ead79d5..a114019 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValue.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValue.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.debug.core.model;
@@ -32,8 +31,8 @@
import org.eclipse.dltk.internal.debug.core.eval.ScriptEvaluationCommand;
import org.eclipse.osgi.util.NLS;
-public class ScriptValue extends ScriptDebugElement implements IScriptValue,
- IIndexedValue {
+public class ScriptValue extends ScriptDebugElement
+ implements IScriptValue, IIndexedValue {
static final IVariable[] NO_VARIABLES = new IVariable[0];
@@ -97,8 +96,8 @@
private void loadPage(int page) throws DbgpException {
IDbgpPropertyCommands commands = frame.getScriptThread()
.getDbgpSession().getCoreCommands();
- IDbgpProperty pageProperty = commands.getProperty(page, fullname, frame
- .getLevel());
+ IDbgpProperty pageProperty = commands.getProperty(page, fullname,
+ frame.getLevel());
fillVariables(page, pageProperty);
final int endIndex = Math.min((page + 1) * pageSize, variables.length);
for (int i = page * pageSize; i < endIndex; ++i) {
@@ -113,8 +112,9 @@
IDbgpProperty[] properties = pageProperty.getAvailableChildren();
final int size = Math.min(properties.length, variables.length - offset);
if (size != properties.length) {
- DLTKDebugPlugin.logWarning(NLS.bind(
- Messages.AvailableChildrenExceedsVariableLength, name),
+ DLTKDebugPlugin.logWarning(
+ NLS.bind(Messages.AvailableChildrenExceedsVariableLength,
+ name),
null);
}
if (size > 0) {
@@ -206,17 +206,14 @@
String snippet = replacePattern(messageTemplate, pattern, evalName);
return new ScriptEvaluationCommand(engine, snippet, frame);
}
- DLTKDebugPlugin
- .logWarning(
- NLS
- .bind(
- Messages.ScriptValue_detailFormatterRequiredToContainIdentifier,
- pattern), null);
+ DLTKDebugPlugin.logWarning(NLS.bind(
+ Messages.ScriptValue_detailFormatterRequiredToContainIdentifier,
+ pattern), null);
return new ScriptEvaluationCommand(engine, evalName, frame);
}
- private static String replacePattern(String messageTemplate,
- String pattern, String evalName) {
+ private static String replacePattern(String messageTemplate, String pattern,
+ String evalName) {
String result = messageTemplate;
while (result.indexOf(pattern) != -1) {
int pos = result.indexOf(pattern);
@@ -241,8 +238,9 @@
}
return variables[offset];
} catch (DbgpException e) {
- throw wrapDbgpException(NLS.bind(
- Messages.ScriptValue_unableToLoadChildrenOf, name), e);
+ throw wrapDbgpException(
+ NLS.bind(Messages.ScriptValue_unableToLoadChildrenOf, name),
+ e);
}
}
@@ -259,9 +257,11 @@
return variables;
}
- public Object getAdapter(Class adapter) {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IIndexedValue.class && type.isCollection()) {
- return this;
+ return (T) this;
}
return super.getAdapter(adapter);
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValueProxy.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValueProxy.java
index d53af19..488fbee 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValueProxy.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptValueProxy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -93,7 +93,8 @@
return origin.getModelIdentifier();
}
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return origin.getAdapter(adapter);
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptVariableWrapperValue.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptVariableWrapperValue.java
index 40ebe4e..333ce49 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptVariableWrapperValue.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptVariableWrapperValue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -65,7 +65,8 @@
return getDebugTarget().getModelIdentifier();
}
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/execution/LocalExecEnvironmentAdapter.java b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/execution/LocalExecEnvironmentAdapter.java
index 6862262..08d9e3f 100644
--- a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/execution/LocalExecEnvironmentAdapter.java
+++ b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/execution/LocalExecEnvironmentAdapter.java
@@ -5,19 +5,23 @@
import org.eclipse.dltk.core.internal.environment.LocalEnvironment;
public class LocalExecEnvironmentAdapter implements IAdapterFactory {
- public static final Class[] ADAPTER_LIST = { IExecutionEnvironment.class };
+ public static final Class<?>[] ADAPTER_LIST = {
+ IExecutionEnvironment.class };
private IExecutionEnvironment localEnvironment = new LocalExecEnvironment();
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adapterType == IExecutionEnvironment.class &&
- adaptableObject instanceof LocalEnvironment) {
- return localEnvironment;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+ if (adapterType == IExecutionEnvironment.class
+ && adaptableObject instanceof LocalEnvironment) {
+ return (T) localEnvironment;
}
return null;
}
- public Class[] getAdapterList() {
- return ADAPTER_LIST;
+ @Override
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
}
}
diff --git a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/process/LaunchProxy.java b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/process/LaunchProxy.java
index 9708984..cf9fd18 100644
--- a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/process/LaunchProxy.java
+++ b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/process/LaunchProxy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -162,10 +162,8 @@
original.terminate();
}
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return original.getAdapter(adapter);
}
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
index ff1ffc9..cbc9bd9 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
@@ -1100,10 +1100,10 @@
}
private IWorkbenchSiteProgressService getProgressService() {
- Object siteService = getSite().getAdapter(
+ IWorkbenchSiteProgressService siteService = getSite().getAdapter(
IWorkbenchSiteProgressService.class);
if (siteService != null)
- return (IWorkbenchSiteProgressService) siteService;
+ return siteService;
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
index f82f318..8d34e4f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -1229,6 +1229,7 @@
}
}
+ @Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class required) {
if (ITemplatesPage.class.equals(required)) {
if (fTemplatesPage == null)
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/model/ScriptModelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/model/ScriptModelProvider.java
index 630ed8c..a3e2e53 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/model/ScriptModelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/model/ScriptModelProvider.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.ui.model;
@@ -44,13 +43,14 @@
resource= (IResource) element;
} else if (element instanceof IAdaptable) {
final IAdaptable adaptable= (IAdaptable) element;
- final Object adapted= adaptable.getAdapter(IResource.class);
- if (adapted instanceof IResource)
- resource= (IResource) adapted;
+ final IResource adapted = adaptable.getAdapter(IResource.class);
+ if (adapted != null)
+ resource = adapted;
} else {
- final Object adapted= Platform.getAdapterManager().getAdapter(element, IResource.class);
- if (adapted instanceof IResource)
- resource= (IResource) adapted;
+ final IResource adapted = Platform.getAdapterManager()
+ .getAdapter(element, IResource.class);
+ if (adapted != null)
+ resource = adapted;
}
return resource;
}
@@ -69,9 +69,10 @@
final IModelElement element= DLTKCore.create(resource);
if (element != null)
return new ResourceMapping[] { DLTKElementResourceMapping.create(element)};
- final Object adapted= resource.getAdapter(ResourceMapping.class);
- if (adapted instanceof ResourceMapping)
- return new ResourceMapping[] { ((ResourceMapping) adapted)};
+ final ResourceMapping adapted = resource
+ .getAdapter(ResourceMapping.class);
+ if (adapted != null)
+ return new ResourceMapping[] { (adapted) };
return new ResourceMapping[] { new DLTKResourceMapping(resource)};
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/OpenEditorActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/OpenEditorActionGroup.java
index de89513..598d8ac 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/OpenEditorActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/OpenEditorActionGroup.java
@@ -137,7 +137,7 @@
if (!(o instanceof IAdaptable))
return;
IAdaptable element = (IAdaptable) o;
- Object resource = element.getAdapter(IResource.class);
+ IResource resource = element.getAdapter(IResource.class);
if (element instanceof IStorage && !(resource instanceof IFile)) {
// Create a menu.
IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label);
@@ -154,7 +154,7 @@
} else if ((resource instanceof IFile)) {
// Create a menu.
IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label);
- submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));
+ submenu.add(new OpenWithMenu(fSite.getPage(), resource));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ScriptCopyProcessor.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ScriptCopyProcessor.java
index 623fe07..2efc851 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ScriptCopyProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ScriptCopyProcessor.java
@@ -165,6 +165,7 @@
return null;
}
+ @Override
public Object getAdapter(Class adapter) {
if (ReorgExecutionLog.class.equals(adapter))
return fExecutionLog;
diff --git a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/ScriptLaunchingTests.java b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/ScriptLaunchingTests.java
index 02fc3f0..7024344 100644
--- a/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/ScriptLaunchingTests.java
+++ b/core/tests/org.eclipse.dltk.core.tests/src/org/eclipse/dltk/core/tests/launching/ScriptLaunchingTests.java
@@ -296,7 +296,7 @@
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}