From 7e9b9c916ed778b044e9b4dde20e5dc94db37956 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Sun, 10 Sep 2017 10:45:18 +0300 Subject: Bug 522095 - Fix info warnings in platform.ua * Use Class.cast instead of cast operator. * Silence unlikely-arg-type warning in tests. Change-Id: Icf3798bc9534a2bd376d91891a00cb5848c4017f Signed-off-by: Alexander Kurtakov --- .../help/org/eclipse/ua/tests/help/other/UAElementTest.java | 3 ++- .../src/org/eclipse/ui/internal/cheatsheets/registry/Category.java | 7 +++---- .../internal/cheatsheets/registry/CheatSheetCollectionElement.java | 3 +-- .../ui/internal/cheatsheets/registry/CheatSheetElement.java | 3 +-- .../cheatsheets/registry/CheatSheetItemExtensionElement.java | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UAElementTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UAElementTest.java index c4e798adc..82d507cd5 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UAElementTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UAElementTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 @@ -31,6 +31,7 @@ public class UAElementTest { private UAElement child4; private UAElement grandchild1; + @SuppressWarnings("unlikely-arg-type") @Test public void testSimpleUAElement() { UAElement element = new UAElement("name1"); diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java index c84fecdf2..34a269b28 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2017 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 @@ -105,13 +105,12 @@ public class Category implements IWorkbenchAdapter, IPluginContribution, elements.add(element); } - @SuppressWarnings("unchecked") @Override public T getAdapter(Class adapter) { if (adapter == IWorkbenchAdapter.class) - return (T) this; + return adapter.cast(this); else if (adapter == IConfigurationElement.class) - return (T) configurationElement; + return adapter.cast(configurationElement); else return null; } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java index ae86a7698..5010876fb 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java @@ -110,10 +110,9 @@ public class CheatSheetCollectionElement extends WorkbenchAdapter implements IPl * associated with this object. Returns null if * no such object can be found. */ - @SuppressWarnings("unchecked") public T getAdapter(Class adapter) { if (adapter == IWorkbenchAdapter.class) { - return (T) this; + return adapter.cast(this); } return Platform.getAdapterManager().getAdapter(this, adapter); } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java index 7d621f896..e08fc9cbb 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java @@ -54,11 +54,10 @@ public class CheatSheetElement extends WorkbenchAdapter implements IAdaptable, I * associated with this object. Returns null if * no such object can be found. */ - @SuppressWarnings("unchecked") @Override public T getAdapter(Class adapter) { if (adapter == IWorkbenchAdapter.class) { - return (T) this; + return adapter.cast(this); } return Platform.getAdapterManager().getAdapter(this, adapter); } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java index 626dcb740..ba945bd51 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java @@ -47,11 +47,10 @@ public class CheatSheetItemExtensionElement extends WorkbenchAdapter implements * associated with this object. Returns null if * no such object can be found. */ - @SuppressWarnings("unchecked") @Override public T getAdapter(Class adapter) { if (adapter == IWorkbenchAdapter.class) { - return (T) this; + return adapter.cast(this); } return Platform.getAdapterManager().getAdapter(this, adapter); } -- cgit v1.2.3