public PerProjectInfo(IProject project) { this.triedRead = false; this.savedState = null; this.project = project; this.javadocCache = new LRUCache<>(JAVADOC_CACHE_INITIAL_SIZE); }
public String toStringFillingRation(String cacheName) { StringBuffer buffer = new StringBuffer(cacheName); buffer.append('['); buffer.append(getSpaceLimit()); buffer.append("]: "); //$NON-NLS-1$ buffer.append(NumberFormat.getInstance().format(fillingRatio())); buffer.append("% full"); //$NON-NLS-1$ return buffer.toString(); }
/** * Ensures there is the specified amount of free space in the receiver, * by removing old entries if necessary. Returns true if the requested space was * made available, false otherwise. * * @param space Amount of space to free up */ protected boolean makeSpace (int space) { int limit; limit = getSpaceLimit(); /* if space is already available */ if (this.currentSpace + space <= limit) { return true; } /* if entry is too big for cache */ if (space > limit) { return false; } /* Free up space by removing oldest entries */ while (this.currentSpace + space > limit && this.entryQueueTail != null) { privateRemoveEntry (this.entryQueueTail, false); } return true; }
newSpace = spaceFor(value); entry = this.entryTable.get (key); newTotal = getCurrentSpace() - oldSpace + newSpace; if (newTotal <= getSpaceLimit()) { updateTimestamp (entry); entry.value = value; entry.space = newSpace; return value; } else { privateRemoveEntry (entry, false); if (makeSpace(newSpace)) { privateAdd (key, value, newSpace);
public synchronized void snapshot() { removeCountersOlderThan(getOldestTimestampCounter()); add(getNewestTimestampCounter()); } }
/** * Returns a String that represents the contents of this object. This method * is for debugging purposes only. */ protected String toStringContents() { StringBuffer result = new StringBuffer(); int length = this.entryTable.size(); Object[] unsortedKeys = new Object[length]; String[] unsortedToStrings = new String[length]; Enumeration e = keys(); for (int i = 0; i < length; i++) { Object key = e.nextElement(); unsortedKeys[i] = key; unsortedToStrings[i] = (key instanceof org.eclipse.jdt.internal.core.JavaElement) ? ((org.eclipse.jdt.internal.core.JavaElement)key).getElementName() : key.toString(); } ToStringSorter sorter = new ToStringSorter(); sorter.sort(unsortedKeys, unsortedToStrings); for (int i = 0; i < length; i++) { String toString = sorter.sortedStrings[i]; Object value = get(sorter.sortedObjects[i]); result.append(toString); result.append(" -> "); //$NON-NLS-1$ result.append(value); result.append("\n"); //$NON-NLS-1$ } return result.toString(); }
/** * Sets the maximum amount of space that the cache can store * * @param limit Number of units of cache space */ public void setSpaceLimit(int limit) { if (limit < this.spaceLimit) { makeSpace(this.spaceLimit - limit); } this.spaceLimit = limit; }
/** * Returns a String that represents the contents of this object. This method * is for debugging purposes only. */ protected String toStringContents() { StringBuffer result = new StringBuffer(); ToStringSorter<K> sorter = new ToStringSorter<>(o -> o instanceof JavaElement ? ((JavaElement) o).getElementName() : o.toString()); List<Pair<K>> sortedObjects = sorter.sort(this.entryTable.keySet()); for (Pair<K> pair : sortedObjects) { String toString = pair.string; V value = get(pair.object); result.append(toString); result.append(" -> "); //$NON-NLS-1$ result.append(value); result.append("\n"); //$NON-NLS-1$ } return result.toString(); }
public long getOldestTimestamps() { return getTimestamps(getOldestTimestampCounter()); } public synchronized void snapshot() {
public Object getOldestElement() { return LRUCache.this.getOldestElement(); } public long getOldestTimestamps() {
newSpace = spaceFor(value); entry = (LRUCacheEntry) this.entryTable.get (key); newTotal = getCurrentSpace() - oldSpace + newSpace; if (newTotal <= getSpaceLimit()) { updateTimestamp (entry); entry.value = value; entry.space = newSpace; return value; } else { privateRemoveEntry (entry, false); if (makeSpace(newSpace)) { privateAdd (key, value, newSpace);
/** * Ensures there is the specified amount of free space in the receiver, * by removing old entries if necessary. Returns true if the requested space was * made available, false otherwise. * * @param space Amount of space to free up */ protected boolean makeSpace (int space) { int limit; limit = getSpaceLimit(); /* if space is already available */ if (this.currentSpace + space <= limit) { return true; } /* if entry is too big for cache */ if (space > limit) { return false; } /* Free up space by removing oldest entries */ while (this.currentSpace + space > limit && this.entryQueueTail != null) { privateRemoveEntry (this.entryQueueTail, false); } return true; } /**
public synchronized void snapshot() { removeCountersOlderThan(getOldestTimestampCounter()); add(getNewestTimestampCounter()); } }
/** * Returns a String that represents the contents of this object. This method * is for debugging purposes only. */ protected String toStringContents() { StringBuffer result = new StringBuffer(); int length = this.entryTable.size(); Object[] unsortedKeys = new Object[length]; String[] unsortedToStrings = new String[length]; Enumeration e = keys(); for (int i = 0; i < length; i++) { Object key = e.nextElement(); unsortedKeys[i] = key; unsortedToStrings[i] = (key instanceof org.eclipse.jdt.internal.core.JavaElement) ? ((org.eclipse.jdt.internal.core.JavaElement)key).getElementName() : key.toString(); } ToStringSorter sorter = new ToStringSorter(); sorter.sort(unsortedKeys, unsortedToStrings); for (int i = 0; i < length; i++) { String toString = sorter.sortedStrings[i]; Object value = get(sorter.sortedObjects[i]); result.append(toString); result.append(" -> "); //$NON-NLS-1$ result.append(value); result.append("\n"); //$NON-NLS-1$ } return result.toString(); }
/** * Sets the maximum amount of space that the cache can store * * @param limit Number of units of cache space */ public void setSpaceLimit(int limit) { if (limit < this.spaceLimit) { makeSpace(this.spaceLimit - limit); } this.spaceLimit = limit; } /**
/** * Returns the info for the element. */ public Object getInfo(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return this.modelInfo; case IJavaElement.JAVA_PROJECT: return this.projectCache.get(element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return this.rootCache.get((IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return this.pkgCache.get((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return this.openableCache.get((ITypeRoot) element); case IJavaElement.TYPE: Object result = this.jarTypeCache.get(element); if (result != null) return result; else return this.childrenCache.get(element); default: return this.childrenCache.get(element); } }
public long getOldestTimestamps() { return getTimestamps(getOldestTimestampCounter()); } public synchronized void snapshot() {
public Object getOldestElement() { return LRUCache.this.getOldestElement(); } public long getOldestTimestamps() {
newSpace = spaceFor(value); entry = (LRUCacheEntry) this.entryTable.get (key); newTotal = getCurrentSpace() - oldSpace + newSpace; if (newTotal <= getSpaceLimit()) { updateTimestamp (entry); entry.value = value; entry.space = newSpace; return value; } else { privateRemoveEntry (entry, false); if (makeSpace(newSpace)) { privateAdd (key, value, newSpace);