List of usage examples for org.eclipse.jdt.internal.core.index Index hasChanged
public boolean hasChanged()
From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java
License:Open Source License
public void saveIndex(Index index) throws IOException { // must have permission to write from the write monitor if (index.hasChanged()) { if (VERBOSE) Util.verbose("-> saving index " + index.getIndexLocation()); //$NON-NLS-1$ index.save();//from www. j a v a2 s . c o m } synchronized (this) { IPath containerPath = new Path(index.containerPath); if (this.jobEnd > this.jobStart) { for (int i = this.jobEnd; i > this.jobStart; i--) { // skip the current job IJob job = this.awaitingJobs[i]; if (job instanceof IndexRequest) if (((IndexRequest) job).containerPath.equals(containerPath)) return; } } IndexLocation indexLocation = computeIndexLocation(containerPath); updateIndexState(indexLocation, SAVED_STATE); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java
License:Open Source License
/** * Commit all index memory changes to disk */// w w w . j a v a 2 s. c o m public void saveIndexes() { // only save cached indexes... the rest were not modified ArrayList toSave = new ArrayList(); synchronized (this) { Object[] valueTable = this.indexes.valueTable; for (int i = 0, l = valueTable.length; i < l; i++) { Index index = (Index) valueTable[i]; if (index != null) toSave.add(index); } } boolean allSaved = true; for (int i = 0, length = toSave.size(); i < length; i++) { Index index = (Index) toSave.get(i); ReadWriteMonitor monitor = index.monitor; if (monitor == null) continue; // index got deleted since acquired try { // take read lock before checking if index has changed // don't take write lock yet since it can cause a deadlock (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50571) monitor.enterRead(); if (index.hasChanged()) { if (monitor.exitReadEnterWrite()) { try { saveIndex(index); } catch (IOException e) { if (VERBOSE) { Util.verbose("-> got the following exception while saving:", System.err); //$NON-NLS-1$ e.printStackTrace(); } allSaved = false; } finally { monitor.exitWriteEnterRead(); } } else { allSaved = false; } } } finally { monitor.exitRead(); } } if (this.participantsContainers != null && this.participantUpdated) { writeParticipantsIndexNamesFile(); this.participantUpdated = false; } this.needToSave = !allSaved; }
From source file:org.eclipse.jdt.internal.core.search.indexing.IndexManager.java
License:Open Source License
public void saveIndex(Index index) throws IOException { // must have permission to write from the write monitor if (index.hasChanged()) { if (VERBOSE) Util.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$ index.save();// ww w .ja va 2 s .com } synchronized (this) { IPath containerPath = new Path(index.containerPath); if (this.jobEnd > this.jobStart) { for (int i = this.jobEnd; i > this.jobStart; i--) { // skip the current job IJob job = this.awaitingJobs[i]; if (job instanceof IndexRequest) if (((IndexRequest) job).containerPath.equals(containerPath)) return; } } IPath indexLocation = computeIndexLocation(containerPath); updateIndexState(indexLocation, SAVED_STATE); } }