From f89725841c5b9c780c628bf80c66ef2ad716158c Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Tue, 19 Dec 2023 12:05:52 +0100 Subject: [PATCH] Suppress warnings for fields hiding other fields There are several fields that hide fields of superclasses because of having the same name and produce according warnings. In some cases this is intended or necessary, so the warnings should be suppressed. These cases comprise: * Class-specific IDs and default objects (like EMPTY) * Fields hiding superclass fields that should not be accessed This change adds the according suppressions. --- .../org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java | 2 ++ .../src/org/eclipse/jface/viewers/TreeSelection.java | 1 + .../org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java | 1 + .../extensions/org/eclipse/ui/actions/MoveProjectAction.java | 1 + .../extensions/org/eclipse/ui/actions/MoveResourceAction.java | 1 + .../extensions/org/eclipse/ui/actions/OpenFileAction.java | 1 + .../tests/api/PerspectiveWithMultiViewPlaceholdersInFolder.java | 1 + .../org/eclipse/ui/tests/api/SaveableMockViewPart.java | 1 + .../org/eclipse/ui/tests/api/UserSaveableMockViewPart.java | 1 + .../org/eclipse/ui/tests/api/UserSaveableSharedViewPart.java | 1 + .../ui/tests/decorators/TestResourceDecoratorContributor.java | 2 ++ .../decorators/TestResourceMappingDecoratorContributor.java | 2 ++ .../tests/decorators/TestUnadaptableDecoratorContributor.java | 2 ++ .../ui/tests/propertysheet/TestNewPropertySheetHandler.java | 1 + 14 files changed, 18 insertions(+) diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java index c554dc9f129..44c188146f4 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java @@ -121,6 +121,7 @@ public void run() { @Inject Logger logger; + @SuppressWarnings("hiding") @Inject private IEclipseContext context; @@ -129,6 +130,7 @@ public void run() { private ThemeDefinitionChangedHandler themeDefinitionChanged; + @SuppressWarnings("hiding") @Inject private EModelService modelService; diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeSelection.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeSelection.java index e6eacc28c98..66b5ae9af92 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeSelection.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeSelection.java @@ -45,6 +45,7 @@ public class TreeSelection extends StructuredSelection implements ITreeSelection * The canonical empty selection. This selection should be used instead of * null. */ + @SuppressWarnings("hiding") public static final TreeSelection EMPTY = new TreeSelection(); private static final TreePath[] EMPTY_TREE_PATHS= new TreePath[0]; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java index 2faced86c74..3d8c3ad6252 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java @@ -57,6 +57,7 @@ public class CloseUnrelatedProjectsAction extends CloseResourceAction { /** * The id of this action. */ + @SuppressWarnings("hiding") public static final String ID = PlatformUI.PLUGIN_ID + ".CloseUnrelatedProjectsAction"; //$NON-NLS-1$ private List projectsToClose = new ArrayList<>(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveProjectAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveProjectAction.java index 3f6e7ba54e5..f6008e29e9b 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveProjectAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveProjectAction.java @@ -48,6 +48,7 @@ public class MoveProjectAction extends CopyProjectAction { /** * The id of this action. */ + @SuppressWarnings("hiding") public static final String ID = PlatformUI.PLUGIN_ID + ".MoveProjectAction";//$NON-NLS-1$ /** diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java index 46168dfb8d2..f2f0ff08898 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java @@ -38,6 +38,7 @@ public class MoveResourceAction extends CopyResourceAction { /** * The id of this action. */ + @SuppressWarnings("hiding") public static final String ID = PlatformUI.PLUGIN_ID + ".MoveResourceAction"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java index 0108478762f..0ad74cdd9af 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java @@ -42,6 +42,7 @@ public class OpenFileAction extends OpenSystemEditorAction { /** * The id of this action. */ + @SuppressWarnings("hiding") public static final String ID = PlatformUI.PLUGIN_ID + ".OpenFileAction";//$NON-NLS-1$ /** diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/PerspectiveWithMultiViewPlaceholdersInFolder.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/PerspectiveWithMultiViewPlaceholdersInFolder.java index cc9df9ca2ee..63b5f0ce628 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/PerspectiveWithMultiViewPlaceholdersInFolder.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/PerspectiveWithMultiViewPlaceholdersInFolder.java @@ -25,6 +25,7 @@ */ public class PerspectiveWithMultiViewPlaceholdersInFolder extends PerspectiveWithMultiViewPlaceholdersInPlaceholderFolder { + @SuppressWarnings("hiding") public static String PERSP_ID = "org.eclipse.ui.tests.PerspectiveWithMultiViewPlaceholdersInFolder"; //$NON-NLS-1$ public PerspectiveWithMultiViewPlaceholdersInFolder() { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java index b243fc53332..b0d3ff2f016 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java @@ -38,6 +38,7 @@ public class SaveableMockViewPart extends MockViewPart implements ISaveablePart, ISaveablesSource { + @SuppressWarnings("hiding") public static String ID = "org.eclipse.ui.tests.api.SaveableMockViewPart"; private boolean isDirty = false; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableMockViewPart.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableMockViewPart.java index 2386efb2fdd..9ab55e00c12 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableMockViewPart.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableMockViewPart.java @@ -25,6 +25,7 @@ public class UserSaveableMockViewPart extends MockViewPart implements ISaveablePart2 { + @SuppressWarnings("hiding") public static String ID = "org.eclipse.ui.tests.api.UserSaveableMockViewPart"; private boolean isDirty = false; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableSharedViewPart.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableSharedViewPart.java index 0606f5e7c47..c2cde22025d 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableSharedViewPart.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/UserSaveableSharedViewPart.java @@ -27,6 +27,7 @@ public class UserSaveableSharedViewPart extends MockViewPart implements /** * The shared ID. */ + @SuppressWarnings("hiding") public static String ID = "org.eclipse.ui.tests.api.UserSaveableSharedViewPart"; public static class SharedModel { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceDecoratorContributor.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceDecoratorContributor.java index 5027376d543..cbee5bafcef 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceDecoratorContributor.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceDecoratorContributor.java @@ -16,7 +16,9 @@ import org.eclipse.core.resources.IResource; public class TestResourceDecoratorContributor extends TestAdaptableDecoratorContributor { + @SuppressWarnings("hiding") public static final String SUFFIX = "IResource.1"; + @SuppressWarnings("hiding") public static final String ID = "org.eclipse.ui.tests.decorators.resourceDescorator"; public TestResourceDecoratorContributor() { setExpectedElementType(IResource.class); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceMappingDecoratorContributor.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceMappingDecoratorContributor.java index 373193bbc47..66d4b8d73d0 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceMappingDecoratorContributor.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestResourceMappingDecoratorContributor.java @@ -17,7 +17,9 @@ public class TestResourceMappingDecoratorContributor extends TestAdaptableDecoratorContributor { + @SuppressWarnings("hiding") public static final String SUFFIX = "ResourceMapping.1"; + @SuppressWarnings("hiding") public static final String ID = "org.eclipse.ui.tests.decorators.resourceMappingDescorator"; public TestResourceMappingDecoratorContributor() { setExpectedElementType(ResourceMapping.class); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestUnadaptableDecoratorContributor.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestUnadaptableDecoratorContributor.java index 18fc3ac0357..31973a1ac50 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestUnadaptableDecoratorContributor.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/TestUnadaptableDecoratorContributor.java @@ -17,7 +17,9 @@ * Decorator used to test an unadaptaed contribution */ public class TestUnadaptableDecoratorContributor extends TestAdaptableDecoratorContributor { + @SuppressWarnings("hiding") public static final String SUFFIX = "ICommon.2"; + @SuppressWarnings("hiding") public static final String ID = "org.eclipse.ui.tests.decorators.generalAdaptabilityOff"; public TestUnadaptableDecoratorContributor() { setSuffix(SUFFIX); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java index 3eed522724c..cba09c6750f 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java @@ -26,6 +26,7 @@ */ public class TestNewPropertySheetHandler extends NewPropertySheetHandler { + @SuppressWarnings("hiding") public static final String ID = NewPropertySheetHandler.ID + "Test"; @Override