### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.ide Index: src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java,v retrieving revision 1.22 diff -u -r1.22 CachedMarkerBuilder.java --- src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java 29 Apr 2008 11:21:01 -0000 1.22 +++ src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java 2 Sep 2008 14:49:09 -0000 @@ -1190,6 +1190,7 @@ monitor.worked(50); currentMap = newMarkers; + currentMap.clearAttributeCaches(); } /** Index: src/org/eclipse/ui/internal/views/markers/MarkerMap.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerMap.java,v retrieving revision 1.4 diff -u -r1.4 MarkerMap.java --- src/org/eclipse/ui/internal/views/markers/MarkerMap.java 3 Apr 2008 17:40:50 -0000 1.4 +++ src/org/eclipse/ui/internal/views/markers/MarkerMap.java 2 Sep 2008 14:49:09 -0000 @@ -127,4 +127,14 @@ public MarkerEntry[] toArray() { return markers; } + + /** + * Clear the caches for the markers. + */ + void clearAttributeCaches() { + for (int i = 0; i < markers.length; i++) { + markers[i].clearCaches(); + } + + } } Index: src/org/eclipse/ui/internal/views/markers/MarkerEntry.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java,v retrieving revision 1.12 diff -u -r1.12 MarkerEntry.java --- src/org/eclipse/ui/internal/views/markers/MarkerEntry.java 30 May 2008 16:10:41 -0000 1.12 +++ src/org/eclipse/ui/internal/views/markers/MarkerEntry.java 2 Sep 2008 14:49:09 -0000 @@ -38,9 +38,8 @@ // The key for the string we built for display private static final Object LOCATION_STRING = "LOCATION_STRING"; //$NON-NLS-1$ - Map attributeCache = new HashMap(0); + Map cache = null; private MarkerCategory category; - Map collationKeys = new HashMap(0); private String folder; IMarker marker; @@ -67,8 +66,8 @@ /* * (non-Javadoc) * - * @see org.eclipse.ui.internal.provisional.views.markers.MarkerItem#getAttributeValue(java.lang.String, - * boolean) + * @seeorg.eclipse.ui.internal.provisional.views.markers.MarkerItem# + * getAttributeValue(java.lang.String, boolean) */ public boolean getAttributeValue(String attribute, boolean defaultValue) { Object value = getAttributeValue(attribute); @@ -80,8 +79,9 @@ /* * (non-Javadoc) * - * @see org.eclipse.ui.views.markers.MarkerItem#getAttributeValue(java.lang.String, - * int) + * @see + * org.eclipse.ui.views.markers.MarkerItem#getAttributeValue(java.lang.String + * , int) */ public int getAttributeValue(String attribute, int defaultValue) { @@ -101,8 +101,8 @@ */ private Object getAttributeValue(String attribute) { Object value; - if (attributeCache.containsKey(attribute)) { - value = attributeCache.get(attribute); + if (getCache().containsKey(attribute)) { + value = getCache().get(attribute); } else { try { value = marker.getAttribute(attribute); @@ -110,14 +110,30 @@ value = null; } // Even cache nulls so that we use the passed defaultValue. - attributeCache.put(attribute, value); + getCache().put(attribute, value); } + + if (value instanceof CollationKey) + return ((CollationKey) value).getSourceString(); return value; } - - /* (non-Javadoc) - * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getAttributeValue(java.lang.String, java.lang.String) + /** + * Get the cache for the receiver. Create if neccessary. + * @return {@link HashMap} + */ + private Map getCache() { + if(cache == null) + cache = new HashMap(2); + return cache; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.internal.views.markers.MarkerSupportItem#getAttributeValue + * (java.lang.String, java.lang.String) */ public String getAttributeValue(String attribute, String defaultValue) { @@ -127,7 +143,7 @@ // The following toString() is a no-op for string attribute // values (which we expect!), but safeguards against clients // who used non-String objects (e.g. Integer) as attribute values, - // see bug 218249. + // see bug 218249. return value.toString(); } @@ -143,7 +159,8 @@ /* * (non-Javadoc) * - * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getChildren() + * @see + * org.eclipse.ui.internal.views.markers.MarkerSupportItem#getChildren() */ MarkerSupportItem[] getChildren() { return MarkerSupportInternalUtilities.EMPTY_MARKER_ITEM_ARRAY; @@ -158,21 +175,35 @@ * @return CollationKey */ CollationKey getCollationKey(String attribute, String defaultValue) { - if (collationKeys.containsKey(attribute)) - return (CollationKey) collationKeys.get(attribute); - String attributeValue = getAttributeValue(attribute, defaultValue); + + String attributeValue; + if (getCache().containsKey(attribute)) { + + Object value = getCache().get(attribute); + + // Only return a collation key otherwise use the value to generate it + if (value instanceof CollationKey) + return (CollationKey) value; + + attributeValue = value.toString(); + } else { + attributeValue = getAttributeValue(attribute, defaultValue); + } + if (attributeValue.length() == 0) return MarkerSupportInternalUtilities.EMPTY_COLLATION_KEY; CollationKey key = Collator.getInstance().getCollationKey( attributeValue); - collationKeys.put(attribute, key); + + getCache().put(attribute, key); return key; } /* * (non-Javadoc) * - * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getCreationTime() + * @see + * org.eclipse.ui.internal.views.markers.MarkerSupportItem#getCreationTime() */ long getCreationTime() { try { @@ -186,7 +217,8 @@ /* * (non-Javadoc) * - * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getDescription() + * @see + * org.eclipse.ui.internal.views.markers.MarkerSupportItem#getDescription() */ String getDescription() { return getAttributeValue(IMarker.MESSAGE, @@ -208,15 +240,19 @@ * @see org.eclipse.ui.views.markers.MarkerItem#getLocation() */ public String getLocation() { - if (attributeCache.containsKey(LOCATION_STRING)) - return (String) attributeCache.get(LOCATION_STRING); + if (getCache().containsKey(LOCATION_STRING)){ + Object value = getCache().get(LOCATION_STRING); + if(value instanceof CollationKey) + return ((CollationKey) value).getSourceString(); + return (String) value; + } // Is the location override set? String locationString = getAttributeValue(IMarker.LOCATION, MarkerSupportInternalUtilities.EMPTY_STRING); if (locationString.length() > 0) { - attributeCache.put(LOCATION_STRING, locationString); + getCache().put(LOCATION_STRING, locationString); return locationString; } @@ -229,7 +265,7 @@ lineNumberString = NLS.bind(MarkerMessages.label_lineNumber, Integer.toString(lineNumber)); - attributeCache.put(LOCATION_STRING, lineNumberString); + getCache().put(LOCATION_STRING, lineNumberString); return lineNumberString; } @@ -246,7 +282,9 @@ /* * (non-Javadoc) * - * @see org.eclipse.ui.internal.views.markers.MarkerSupportItem#getMarkerTypeName() + * @see + * org.eclipse.ui.internal.views.markers.MarkerSupportItem#getMarkerTypeName + * () */ String getMarkerTypeName() { try { @@ -347,6 +385,13 @@ */ void setMarker(IMarker marker) { this.marker = marker; - attributeCache.clear(); + clearCaches(); + } + + /** + * Clear the cached values for performance reasons. + */ + void clearCaches() { + cache = null; } }