From 84f46a4ca225c643bab0eb26c589d6169677e0ed 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: Thu, 16 Jan 2025 13:15:36 +0200 Subject: [PATCH] Deprecate for removal JavaPlugin.getJavaCorePluginPreferences Class org.eclipse.core.runtime.Preferences has been deprecated for years and method getJavaCorePluginPreferencesNew (returning IEclipsePreferences) is there. Migrated unit tests to use getJavaCorePluginPreferencesNew. --- .../quickfix/AdvancedQuickAssistTest.java | 14 +++--- .../quickfix/AdvancedQuickAssistTest1d7.java | 14 +++--- .../ui/tests/quickfix/AssistQuickFixTest.java | 48 +++++++++---------- .../tests/quickfix/AssistQuickFixTest1d7.java | 14 +++--- .../quickfix/ChangeNonStaticToStaticTest.java | 14 +++--- .../ui/tests/quickfix/CleanUpTestCase.java | 14 +++--- .../PropertiesFileQuickAssistTest.java | 15 +++--- .../quickfix/SurroundWithTemplateTest.java | 46 +++++++++--------- .../eclipse/jdt/internal/ui/JavaPlugin.java | 10 +++- 9 files changed, 97 insertions(+), 92 deletions(-) diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java index 5277e7918d7..1b40e4fb274 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 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 @@ -32,7 +32,7 @@ import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.TestOptions; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -77,11 +77,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java index 0f2370a1cb6..6a3e0e0ee59 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2020 IBM Corporation and others. + * Copyright (c) 2011, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -24,7 +24,7 @@ import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.TestOptions; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -72,11 +72,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java index ede1e0076e6..2abf0f46e6b 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 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 @@ -37,7 +37,7 @@ import org.eclipse.jdt.testplugin.TestOptions; import org.eclipse.osgi.util.NLS; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -97,11 +97,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); @@ -233,9 +233,9 @@ public void testAssignToLocal3() throws Exception { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); - corePrefs.setValue(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + corePrefs.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_"); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -358,10 +358,10 @@ public void testAssignToLocal5() throws Exception { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg"); - corePrefs.setValue(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg"); + corePrefs.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_"); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -1280,8 +1280,8 @@ public E(int count) { @Test public void testAssignParamToField2() throws Exception { - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -1322,8 +1322,8 @@ public E(int count, Vector vec[]) { @Test public void testAssignParamToField3() throws Exception { - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg"); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true); @@ -1718,8 +1718,8 @@ public void foo(int count, long size, boolean state) { @Test public void testAssignParamToFieldInGeneric() throws Exception { - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -7400,10 +7400,10 @@ public Object foo(final String name) { @Test public void testConvertAnonymousToNested2() throws Exception { - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); - corePrefs.setValue(JavaCore.CODEASSIST_LOCAL_PREFIXES, "l"); - corePrefs.setValue(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, "p"); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + corePrefs.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, "l"); + corePrefs.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, "p"); IPackageFragment pack1= fSourceFolder.createPackageFragment("pack", false, null); String str= """ diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java index aa19cbaa269..0b18095e27a 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 IBM Corporation and others. + * Copyright (c) 2011, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -24,7 +24,7 @@ import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.TestOptions; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -80,11 +80,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ChangeNonStaticToStaticTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ChangeNonStaticToStaticTest.java index 7ee24707c95..b614853a985 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ChangeNonStaticToStaticTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ChangeNonStaticToStaticTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 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 @@ -27,7 +27,7 @@ import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -78,11 +78,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java index 96de0ca5c98..7235edc1152 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2020 IBM Corporation and others. + * Copyright (c) 2005, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -33,7 +33,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.resources.IWorkspace; @@ -106,11 +106,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.OVERRIDECOMMENT_ID, "/* comment */", null); StubUtility.setCodeTemplate(CodeTemplateContextType.FIELDCOMMENT_ID, FIELD_COMMENT, null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fSourceFolder= JavaProjectHelper.addSourceContainer(getProject(), "src"); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/PropertiesFileQuickAssistTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/PropertiesFileQuickAssistTest.java index 576860756ef..6d76954d88e 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/PropertiesFileQuickAssistTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/PropertiesFileQuickAssistTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2020 IBM Corporation and others. + * Copyright (c) 2011, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -35,7 +35,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -95,13 +95,12 @@ public void setUp() throws Exception { JavaProjectHelper.addLibrary(fJProject, JavaProjectHelper.findRtJar(osgiJar)[0]); } - @Deprecated private void setPreferences() { - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java index 79c25685aa0..6ab3fba25ba 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 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 @@ -28,7 +28,7 @@ import org.eclipse.jdt.testplugin.TestOptions; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.text.templates.TemplatePersistenceData; @@ -77,11 +77,11 @@ public void setUp() throws Exception { StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); - Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences(); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); - corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); + IEclipsePreferences corePrefs= JavaPlugin.getJavaCorePluginPreferencesNew(); + corePrefs.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); + corePrefs.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1= projectSetup.getProject(); @@ -126,7 +126,7 @@ public void foo() { System.out.println(1); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -150,7 +150,7 @@ public void run() { }; } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -174,7 +174,7 @@ public void foo() { System.out.println(j); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -210,7 +210,7 @@ public void run() { System.out.println(j); } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -236,7 +236,7 @@ public void foo() { i++; } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -274,7 +274,7 @@ public void run() { i++; } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -338,7 +338,7 @@ public void foo() { System.out.println(i); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -364,7 +364,7 @@ public void run() { System.out.println(i); } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -382,7 +382,7 @@ public void foo() { System.out.println(i); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -410,7 +410,7 @@ public void run() { System.out.println(i); } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -427,7 +427,7 @@ public void foo() { System.out.println(i); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -452,7 +452,7 @@ public void run() { }; } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -474,7 +474,7 @@ public void foo() { System.out.println(i); } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -506,7 +506,7 @@ public void run() { }; } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } @@ -569,7 +569,7 @@ public void foo() { j = 10; } } - + """; ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); @@ -598,7 +598,7 @@ public void run() { j = 10; } } - + """; assertExpectedExistInProposals(proposals, new String[] {str2}); } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java index 3507fea5aaa..91d35681f96 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2021 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 @@ -655,12 +655,18 @@ public JavaTextTools getJavaTextTools() { * * @return the Java Core plug-in preferences * @since 3.7 - * deprecated use getJavaCorePluginPreferencesNew + * @deprecated Use {@link #getJavaCorePluginPreferencesNew()} instead. */ + @Deprecated(forRemoval= true, since="2025-03") public static org.eclipse.core.runtime.Preferences getJavaCorePluginPreferences() { return JavaCore.getPlugin().getPluginPreferences(); } + /** + * Returns the Java Core plug-in preferences. + * + * @return the Java Core plug-in preferences + */ public static IEclipsePreferences getJavaCorePluginPreferencesNew() { return InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID); }