From 3978dd1994fdcae1e3f0b26d3e3a8df6f90f8839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 21 Jan 2025 19:31:35 +0200 Subject: [PATCH 1/2] Reduce 'new Class[]' cases Varargs, use {} for creating arrays and etc. --- .../eclipse/core/databinding/UpdateStrategy.java | 11 +++++------ .../internal/databinding/ClassLookupSupport.java | 4 ++-- .../conversion/IdentityConverter.java | 4 ++-- .../validation/ObjectToPrimitiveValidator.java | 4 ++-- .../workbench/swt/SelectionAdapterFactory.java | 4 ++-- .../text/FileEditorInputAdapterFactory.java | 4 ++-- .../text/IURIEditorInputAdapterFactory.java | 4 ++-- .../databinding/ducks/ReflectedMethod.java | 6 +++--- .../databinding/ducks/ReflectedProperty.java | 8 ++++---- .../databinding/ducks/RelaxedDuckType.java | 4 ++-- ...nippet048TreeViewerTabWithCheckboxFor3_3.java | 4 ++-- .../AbstractFileBufferDocCreationTests.java | 16 ++++++++-------- .../jface/tests/viewers/TableViewerTest.java | 4 ++-- 13 files changed, 38 insertions(+), 39 deletions(-) diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java index 1850ba99851..2363369c471 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 IBM Corporation and others. + * Copyright (c) 2007, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -422,12 +422,11 @@ private synchronized static Map getConverterMap() { return converterMap; } - private static final Class[] integerClasses = new Class[] { byte.class, - Byte.class, short.class, Short.class, int.class, Integer.class, - long.class, Long.class, BigInteger.class }; + private static final Class[] integerClasses = { byte.class, Byte.class, short.class, Short.class, int.class, + Integer.class, long.class, Long.class, BigInteger.class }; - private static final Class[] floatClasses = new Class[] { float.class, - Float.class, double.class, Double.class, BigDecimal.class }; + private static final Class[] floatClasses = { float.class, Float.class, double.class, Double.class, + BigDecimal.class }; /** * Registers converters to boxed and unboxed types from a list of from diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/ClassLookupSupport.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/ClassLookupSupport.java index ba8b41d2fd3..3d68e153b38 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/ClassLookupSupport.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/ClassLookupSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -53,7 +53,7 @@ public static Class[] getTypeHierarchyFlattened(Class type) { classSearchOrderLookup = lookup = new HashMap<>(); lookup.put(type, classes); } - return classes.toArray(new Class[classes.size()]); + return classes.toArray(Class[]::new); } /** diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/IdentityConverter.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/IdentityConverter.java index eaa895f8aff..c9a4fa889f3 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/IdentityConverter.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/IdentityConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com and others. + * Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com and others. * * * This program and the accompanying materials @@ -37,7 +37,7 @@ public IdentityConverter(Class fromType, Class toType) { this.toType = toType; } - private Class[][] primitiveMap = new Class[][] { + private Class[][] primitiveMap = { { Integer.TYPE, Integer.class }, { Short.TYPE, Short.class }, { Long.TYPE, Long.class }, { Double.TYPE, Double.class }, { Byte.TYPE, Byte.class }, { Float.TYPE, Float.class }, diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ObjectToPrimitiveValidator.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ObjectToPrimitiveValidator.java index 8ad76ee09c9..1a5e36f4aca 100755 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ObjectToPrimitiveValidator.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ObjectToPrimitiveValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -28,7 +28,7 @@ public class ObjectToPrimitiveValidator implements IValidator { private Class toType; - private Class[][] primitiveMap = new Class[][] { + private Class[][] primitiveMap = { { Integer.TYPE, Integer.class }, { Short.TYPE, Short.class }, { Long.TYPE, Long.class }, { Double.TYPE, Double.class }, { Byte.TYPE, Byte.class }, { Float.TYPE, Float.class }, diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java index eec792a64b0..be0e8685619 100644 --- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java +++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -40,7 +40,7 @@ public class SelectionAdapterFactory implements IAdapterFactory { /** * The classes we can adapt to. */ - private static final Class[] CLASSES = new Class[] { IIterable.class, ICountable.class }; + private static final Class[] CLASSES = { IIterable.class, ICountable.class }; @Override public T getAdapter(Object adaptableObject, Class adapterType) { diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java index 2a8b4d90598..bcfb65ced28 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -43,7 +43,7 @@ public IPath getPath(Object element) { } /** The list of provided adapters. */ - private static final Class[] ADAPTER_LIST= new Class[] { ILocationProvider.class }; + private static final Class[] ADAPTER_LIST = { ILocationProvider.class }; /** The provided location provider */ private ILocationProvider fLocationProvider= new LocationProvider(); diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java index 774b5188a74..d992159976c 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -57,7 +57,7 @@ public URI getURI(Object element) { /** The list of provided adapters. */ - private static final Class[] ADAPTER_LIST= new Class[] { ILocationProvider.class }; + private static final Class[] ADAPTER_LIST = { ILocationProvider.class }; /** The provided location provider */ private ILocationProvider fLocationProvider= new LocationProvider(); diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java index dbd725a6dd3..565001c21cf 100644 --- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java +++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com + * Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com * * * This program and the accompanying materials @@ -35,7 +35,7 @@ public class ReflectedMethod { * @param methodName The name of the method. * @param paramTypes The method's parameter types. */ - public ReflectedMethod(Object subject, String methodName, Class[] paramTypes) { + public ReflectedMethod(Object subject, String methodName, Class... paramTypes) { this.subject = subject; method = null; try { @@ -62,7 +62,7 @@ public boolean exists() { * @return any return value or null if there was no return value or an error * occured. */ - public Object invoke(Object[] params) { + public Object invoke(Object... params) { if (method == null) return null; try { diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedProperty.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedProperty.java index 6cf2f77bbe0..2a4de650244 100644 --- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedProperty.java +++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedProperty.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 The Pampered Chef and others. + * Copyright (c) 2006, 2025 The Pampered Chef and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -32,14 +32,14 @@ public class ReflectedProperty { */ public ReflectedProperty(Object object, String propertyName) { this.propertyName = propertyName; - getter = new ReflectedMethod(object, makeGetterName(propertyName), new Class[] {}); + getter = new ReflectedMethod(object, makeGetterName(propertyName)); if (!getter.exists()) { - getter = new ReflectedMethod(object, makeBooleanGetterName(propertyName), new Class[] {}); + getter = new ReflectedMethod(object, makeBooleanGetterName(propertyName)); if (!getter.exists()) { throw new IllegalArgumentException("Cannot find getter for " + propertyName); } } - setter = new ReflectedMethod(object, makeSetterName(propertyName), new Class[] { getter.getType() }); + setter = new ReflectedMethod(object, makeSetterName(propertyName), getter.getType()); } private String makeBooleanGetterName(String propertyName) { diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/RelaxedDuckType.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/RelaxedDuckType.java index 49d0aa43007..b6ea9bb9b79 100644 --- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/RelaxedDuckType.java +++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/RelaxedDuckType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com + * Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com * * * This program and the accompanying materials @@ -38,7 +38,7 @@ public static Object implement(Class interfaceToImplement, Object object) { new RelaxedDuckType(object)); } - public static boolean includes(Object object, String method, Class[] args) { + public static boolean includes(Object object, String method, Class... args) { try { object.getClass().getMethod(method, args); } catch (NoSuchMethodException e) { diff --git a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet048TreeViewerTabWithCheckboxFor3_3.java b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet048TreeViewerTabWithCheckboxFor3_3.java index 72ad5057e59..b3c6b0289de 100644 --- a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet048TreeViewerTabWithCheckboxFor3_3.java +++ b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet048TreeViewerTabWithCheckboxFor3_3.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2018 Tom Schindl and others. + * Copyright (c) 2006, 2025 Tom Schindl and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -191,7 +191,7 @@ protected void setValue(Object element, Object value) { ViewerCell cell = mgr.getFocusCell(); try { - Method m = ColumnViewerEditor.class.getDeclaredMethod("processTraverseEvent", new Class[] {int.class,ViewerRow.class,TraverseEvent.class}); + Method m = ColumnViewerEditor.class.getDeclaredMethod("processTraverseEvent", int.class,ViewerRow.class,TraverseEvent.class); m.setAccessible(true); m.invoke(editor, Integer.valueOf(cell.getColumnIndex()), cell.getViewerRow(), e); } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e1) { diff --git a/tests/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java b/tests/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java index 04ac05b136f..c91f12241af 100644 --- a/tests/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java +++ b/tests/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Symbian Software Systems, IBM Corporation and others. + * Copyright (c) 2008, 2025 Symbian Software Systems, IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -44,32 +44,32 @@ public abstract class AbstractFileBufferDocCreationTests { @Test public void testCreateDocumentPartipants_FileExt() { - assertParticipantsInvoked("anything.111foo", new Class[] {TestDSP1.class, TestDSP3.class}); + assertParticipantsInvoked("anything.111foo", TestDSP1.class, TestDSP3.class); } @Test public void testCreateDocumentPartipants_Name() { - assertParticipantsInvoked("111fooname", new Class[] {TestDSP2.class, TestDSP3.class}); + assertParticipantsInvoked("111fooname", TestDSP2.class, TestDSP3.class); } @Test public void testCreateDocumentPartipants_FileExt_Name() { - assertParticipantsInvoked("111fooname.111foo", new Class[] {TestDSP1.class, TestDSP2.class, TestDSP3.class}); + assertParticipantsInvoked("111fooname.111foo", TestDSP1.class, TestDSP2.class, TestDSP3.class); } @Test public void testCreateDocumentPartipants_FileExt_Extension() { - assertParticipantsInvoked("anything.222foo", new Class[] {TestDSP4.class, TestDSP6.class}); + assertParticipantsInvoked("anything.222foo", TestDSP4.class, TestDSP6.class); } @Test public void testCreateDocumentPartipants_Name_Extension() { - assertParticipantsInvoked("222fooname", new Class[] {TestDSP5.class, TestDSP6.class}); + assertParticipantsInvoked("222fooname", TestDSP5.class, TestDSP6.class); } @Test public void testCreateDocumentPartipants_FileExt_Name_Extension() { - assertParticipantsInvoked("222fooname.222foo", new Class[] {TestDSP4.class, TestDSP5.class, TestDSP6.class}); + assertParticipantsInvoked("222fooname.222foo", TestDSP4.class, TestDSP5.class, TestDSP6.class); } @Test @@ -119,7 +119,7 @@ public void testDocumentSetupParticipantExtension_3() { /* Utilities */ - private void assertParticipantsInvoked(String path, Class[] expectedDSPsArray) { + private void assertParticipantsInvoked(String path, Class... expectedDSPsArray) { LocationKind[] lks= getSupportLocationKinds(); for (LocationKind lk : lks) { IDocument document= fManager.createEmptyDocument(IPath.fromOSString(path), lk); diff --git a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TableViewerTest.java b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TableViewerTest.java index 9231573ad77..e46095a8b88 100644 --- a/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TableViewerTest.java +++ b/tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/TableViewerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 3034 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -96,7 +96,7 @@ protected StructuredViewer createViewer(Composite parent) { ViewerColumn getViewerColumn(ColumnViewer viewer, int index) { Method method; try { - method = ColumnViewer.class.getDeclaredMethod("getViewerColumn", new Class[] { int.class }); + method = ColumnViewer.class.getDeclaredMethod("getViewerColumn", int.class); method.setAccessible(true); return (ViewerColumn) method.invoke(viewer, Integer.valueOf(index)); } catch (Exception e) { From 356a475a09711f64138f2a7c4683fb04d5d1ddfc Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Wed, 22 Jan 2025 07:19:19 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.35 stream --- bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF | 2 +- tests/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF index e2b49258d56..e8b2e9d471f 100644 --- a/bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.databinding -Bundle-Version: 1.13.300.qualifier +Bundle-Version: 1.13.400.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.databinding, diff --git a/tests/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF index d5b4ab18722..75ae0c845b5 100644 --- a/tests/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.core.filebuffers.tests;singleton:=true -Bundle-Version: 3.13.400.qualifier +Bundle-Version: 3.13.500.qualifier Bundle-Activator: org.eclipse.core.filebuffers.tests.FileBuffersTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %Plugin.providerName