Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 37884 Details for
Bug 109691
Importing preferences does not update classpath variables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and regression test
109691.txt (text/plain), 9.62 KB, created by
Jerome Lanneluc
on 2006-04-06 10:41:40 EDT
(
hide
)
Description:
Proposed patch and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2006-04-06 10:41:40 EDT
Size:
9.62 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.150 >diff -u -r1.150 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 6 Apr 2006 02:17:29 -0000 1.150 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 6 Apr 2006 14:34:42 -0000 >@@ -128,12 +128,6 @@ > entry, > decoded); > } >-protected void assertMarkers(String message, String expectedMarkers, IJavaProject project) throws CoreException { >- waitForAutoBuild(); >- IMarker[] markers = project.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); >- this.sortMarkers(markers); >- assertMarkers(message, expectedMarkers, markers); >-} > protected void assertStatus(String expected, IStatus status) { > String actual = status.getMessage(); > if (!expected.equals(actual)) { >@@ -179,16 +173,6 @@ > return result; > } > >-protected void sortMarkers(IMarker[] markers) { >- org.eclipse.jdt.internal.core.util.Util.Comparer comparer = new org.eclipse.jdt.internal.core.util.Util.Comparer() { >- public int compare(Object a, Object b) { >- IMarker markerA = (IMarker)a; >- IMarker markerB = (IMarker)b; >- return markerA.getAttribute(IMarker.MESSAGE, "").compareTo(markerB.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- }; >- org.eclipse.jdt.internal.core.util.Util.sort(markers, comparer); >-} > /** > * Add an entry to the classpath for a non-existent root. Then create > * the root and ensure that it comes alive. >Index: src/org/eclipse/jdt/core/tests/model/OptionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java,v >retrieving revision 1.21 >diff -u -r1.21 OptionTests.java >--- src/org/eclipse/jdt/core/tests/model/OptionTests.java 5 Apr 2006 14:03:00 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/model/OptionTests.java 6 Apr 2006 14:34:42 -0000 >@@ -506,6 +506,23 @@ > preferences.get(JavaModelManager.CP_VARIABLE_PREFERENCES_PREFIX+"TEST", "null")); > } > >+ /* >+ * Ensures that classpath problems are removed when missing classpath variable is added through the preferences >+ * (regression test for bug 109691 Importing preferences does not update classpath variables) >+ */ >+ public void test12() throws CoreException { >+ IEclipsePreferences preferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); >+ try { >+ IJavaProject project = createJavaProject("P", new String[0], new String[] {"TEST"}, ""); >+ waitForAutoBuild(); >+ preferences.put(JavaModelManager.CP_VARIABLE_PREFERENCES_PREFIX+"TEST", getExternalJCLPathString()); >+ assertMarkers("Unexpected markers", "", project); >+ } finally { >+ deleteProject("P"); >+ preferences.remove(JavaModelManager.CP_VARIABLE_PREFERENCES_PREFIX+"TEST"); >+ } >+ } >+ > /** > * Bug 68993: [Preferences] IAE when opening project preferences > * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=68993" >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.163 >diff -u -r1.163 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 29 Mar 2006 04:03:08 -0000 1.163 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 6 Apr 2006 14:34:40 -0000 >@@ -370,6 +370,22 @@ > } > assertEquals("Unexpected type hierarchy", expected, actual); > } >+ protected void assertMarkers(String message, String expectedMarkers, IJavaProject project) throws CoreException { >+ waitForAutoBuild(); >+ IMarker[] markers = project.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); >+ sortMarkers(markers); >+ assertMarkers(message, expectedMarkers, markers); >+ } >+ protected void sortMarkers(IMarker[] markers) { >+ org.eclipse.jdt.internal.core.util.Util.Comparer comparer = new org.eclipse.jdt.internal.core.util.Util.Comparer() { >+ public int compare(Object a, Object b) { >+ IMarker markerA = (IMarker)a; >+ IMarker markerB = (IMarker)b; >+ return markerA.getAttribute(IMarker.MESSAGE, "").compareTo(markerB.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ }; >+ org.eclipse.jdt.internal.core.util.Util.sort(markers, comparer); >+ } > protected void assertMarkers(String message, String expectedMarkers, IMarker[] markers) throws CoreException { > StringBuffer buffer = new StringBuffer(); > if (markers != null) { >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.538 >diff -u -r1.538 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 6 Apr 2006 01:47:52 -0000 1.538 >+++ model/org/eclipse/jdt/core/JavaCore.java 6 Apr 2006 14:34:46 -0000 >@@ -3896,7 +3896,7 @@ > IProgressMonitor monitor) { > > try { >- JavaModelManager.getJavaModelManager().updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor); >+ JavaModelManager.getJavaModelManager().updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, true/*update preferences*/, monitor); > } catch (JavaModelException e) { > // cannot happen: ignore > } >@@ -4320,7 +4320,7 @@ > throws JavaModelException { > > if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$ >- JavaModelManager.getJavaModelManager().updateVariableValues(variableNames, paths, monitor); >+ JavaModelManager.getJavaModelManager().updateVariableValues(variableNames, paths, true/*update preferences*/, monitor); > } > > /** >Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v >retrieving revision 1.334 >diff -u -r1.334 JavaModelManager.java >--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 5 Apr 2006 14:02:49 -0000 1.334 >+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 6 Apr 2006 14:34:48 -0000 >@@ -1043,10 +1043,16 @@ > } > } else { > String newValue = (String)event.getNewValue(); >+ IPath newPath; > if (newValue != null && !(newValue = newValue.trim()).equals(CP_ENTRY_IGNORE)) { >- manager.variables.put(varName, new Path(newValue)); >+ newPath = new Path(newValue); > } else { >- manager.variables.remove(varName); >+ newPath = null; >+ } >+ try { >+ manager.updateVariableValues(new String[] {varName}, new IPath[] {newPath}, false/*don't update preferences*/, null/*no progress available*/); >+ } catch (JavaModelException e) { >+ Util.log(e, "Could not set classpath variable " + varName + " to " + newPath); //$NON-NLS-1$ //$NON-NLS-2$ > } > } > } >@@ -2940,13 +2946,16 @@ > void save() throws IOException, JavaModelException { > saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects()); > >- // don't save classpath variables from the default preferences as there is no delta if they are removed >+ // remove variables that should not be saved > HashMap varsToSave = null; >- Iterator iterator = JavaModelManager.this.variables.keySet().iterator(); >+ Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); > IEclipsePreferences defaultPreferences = getDefaultPreferences(); > while (iterator.hasNext()) { >- String varName = (String) iterator.next(); >- if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null) { >+ Map.Entry entry = (Map.Entry) iterator.next(); >+ String varName = (String) entry.getKey(); >+ if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed >+ || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { >+ > if (varsToSave == null) > varsToSave = new HashMap(JavaModelManager.this.variables); > varsToSave.remove(varName); >@@ -3826,6 +3835,7 @@ > public void updateVariableValues( > String[] variableNames, > IPath[] variablePaths, >+ boolean updatePreferences, > IProgressMonitor monitor) throws JavaModelException { > > if (monitor != null && monitor.isCanceled()) return; >@@ -3921,7 +3931,9 @@ > } > // update variables > for (int i = 0; i < varLength; i++){ >- this.variablePut(variableNames[i], variablePaths[i]); >+ variablePut(variableNames[i], variablePaths[i]); >+ if (updatePreferences) >+ variablePreferencesPut(variableNames[i], variablePaths[i]); > } > final String[] dbgVariableNames = variableNames; > >@@ -4024,7 +4036,9 @@ > // discard obsoleted information about previous session > this.previousSessionVariables.remove(variableName); > } >- >+ } >+ >+ private void variablePreferencesPut(String variableName, IPath variablePath) { > String variableKey = CP_VARIABLE_PREFERENCES_PREFIX+variableName; > if (variablePath == null) { > this.variablesWithInitializer.remove(variableName);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 109691
: 37884