Search in sources :

Example 6 with StorageException

use of com.intellij.util.indexing.StorageException in project intellij-community by JetBrains.

the class CompilerReferenceServiceImpl method calculateDirectInheritors.

private Map<VirtualFile, Object[]> calculateDirectInheritors(@NotNull PsiNamedElement aClass, @NotNull GlobalSearchScope useScope, @NotNull FileType searchFileType, @NotNull CompilerHierarchySearchType searchType) {
    final CompilerElementInfo searchElementInfo = asCompilerElements(aClass, false);
    if (searchElementInfo == null)
        return null;
    LightRef searchElement = searchElementInfo.searchElements[0];
    myReadDataLock.lock();
    try {
        if (myReader == null)
            return null;
        try {
            return myReader.getDirectInheritors(searchElement, useScope, myDirtyScopeHolder.getDirtyScope(), searchFileType, searchType);
        } catch (StorageException e) {
            throw new RuntimeException(e);
        }
    } finally {
        myReadDataLock.unlock();
    }
}
Also used : LightRef(org.jetbrains.jps.backwardRefs.LightRef) StorageException(com.intellij.util.indexing.StorageException)

Example 7 with StorageException

use of com.intellij.util.indexing.StorageException in project intellij-community by JetBrains.

the class MapIndexStorage method close.

@Override
public void close() throws StorageException {
    try {
        flush();
        myMap.close();
    } catch (IOException e) {
        throw new StorageException(e);
    } catch (RuntimeException e) {
        unwrapCauseAndRethrow(e);
    }
}
Also used : IOException(java.io.IOException) StorageException(com.intellij.util.indexing.StorageException)

Example 8 with StorageException

use of com.intellij.util.indexing.StorageException in project intellij-community by JetBrains.

the class MapIndexStorage method addValue.

@Override
public void addValue(final Key key, final int inputId, final Value value) throws StorageException {
    if (myReadOnly) {
        throw new IncorrectOperationException("Index storage is read-only");
    }
    try {
        myMap.markDirty();
        if (!myKeyIsUniqueForIndexedFile) {
            read(key).addValue(inputId, value);
            return;
        }
        ChangeTrackingValueContainer<Value> cached;
        try {
            l.lock();
            cached = myCache.getIfCached(key);
        } finally {
            l.unlock();
        }
        if (cached != null) {
            cached.addValue(inputId, value);
            return;
        }
        // do not pollute the cache with keys unique to indexed file
        ChangeTrackingValueContainer<Value> valueContainer = new ChangeTrackingValueContainer<Value>(null);
        valueContainer.addValue(inputId, value);
        myMap.put(key, valueContainer);
    } catch (IOException e) {
        throw new StorageException(e);
    }
}
Also used : IncorrectOperationException(com.intellij.util.IncorrectOperationException) IOException(java.io.IOException) StorageException(com.intellij.util.indexing.StorageException)

Example 9 with StorageException

use of com.intellij.util.indexing.StorageException in project intellij-community by JetBrains.

the class VcsLogPersistentIndex method filterMessages.

@NotNull
public TIntHashSet filterMessages(@NotNull VcsLogTextFilter filter) {
    if (myIndexStorage != null) {
        try {
            if (!filter.isRegex()) {
                TIntHashSet commitsForSearch = myIndexStorage.trigrams.getCommitsForSubstring(filter.getText());
                if (commitsForSearch != null) {
                    TIntHashSet result = new TIntHashSet();
                    commitsForSearch.forEach(commit -> {
                        try {
                            String value = myIndexStorage.messages.get(commit);
                            if (value != null) {
                                if (VcsLogTextFilterImpl.matches(filter, value)) {
                                    result.add(commit);
                                }
                            }
                        } catch (IOException e) {
                            myFatalErrorsConsumer.consume(this, e);
                            return false;
                        }
                        return true;
                    });
                    return result;
                }
            }
        } catch (StorageException e) {
            myFatalErrorsConsumer.consume(this, e);
        } catch (RuntimeException e) {
            processRuntimeException(e);
        }
        return filter(myIndexStorage.messages, message -> VcsLogTextFilterImpl.matches(filter, message));
    }
    return EmptyIntHashSet.INSTANCE;
}
Also used : IOException(java.io.IOException) StorageException(com.intellij.util.indexing.StorageException) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StorageException (com.intellij.util.indexing.StorageException)9 IOException (java.io.IOException)7 TIntHashSet (gnu.trove.TIntHashSet)2 NotNull (org.jetbrains.annotations.NotNull)2 LightRef (org.jetbrains.jps.backwardRefs.LightRef)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 Nullable (org.jetbrains.annotations.Nullable)1