use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class FileBasedIndexImpl method projectIndexableFiles.
@Nullable
public ProjectIndexableFilesFilter projectIndexableFiles(@Nullable Project project) {
if (project == null || myUpdatingFiles.get() > 0)
return null;
if (myProjectsBeingUpdated.contains(project))
return null;
SoftReference<ProjectIndexableFilesFilter> reference = project.getUserData(ourProjectFilesSetKey);
ProjectIndexableFilesFilter data = com.intellij.reference.SoftReference.dereference(reference);
if (data != null && data.myModificationCount == myFilesModCount)
return data;
if (myCalcIndexableFilesLock.tryLock()) {
// make best effort for calculating filter
try {
reference = project.getUserData(ourProjectFilesSetKey);
data = com.intellij.reference.SoftReference.dereference(reference);
if (data != null && data.myModificationCount == myFilesModCount) {
return data;
}
long start = System.currentTimeMillis();
final TIntArrayList filesSet = new TIntArrayList();
iterateIndexableFiles(fileOrDir -> {
ProgressManager.checkCanceled();
filesSet.add(((VirtualFileWithId) fileOrDir).getId());
return true;
}, project, SilentProgressIndicator.create());
ProjectIndexableFilesFilter filter = new ProjectIndexableFilesFilter(filesSet, myFilesModCount);
project.putUserData(ourProjectFilesSetKey, new SoftReference<>(filter));
long finish = System.currentTimeMillis();
LOG.debug(filesSet.size() + " files iterated in " + (finish - start) + " ms");
return filter;
} finally {
myCalcIndexableFilesLock.unlock();
}
}
// ok, no filtering
return null;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class PerFileConfigurableBase method findRow.
protected int[] findRow(VirtualFile file, boolean strict, boolean all) {
TIntArrayList rows = new TIntArrayList();
List<Pair<Object, T>> reversed = ContainerUtil.reverse(myModel.data);
for (int i = 0, size = reversed.size(); i < size; i++) {
Pair<Object, T> p = reversed.get(i);
if (keyMatches(p.first, file, strict)) {
rows.add(size - i - 1);
if (!all)
break;
}
}
return rows.toNativeArray();
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class PerFileConfigurableBase method doAddFiles.
private void doAddFiles(@NotNull List<VirtualFile> files) {
Set<VirtualFile> chosen = ContainerUtil.newHashSet(files);
if (chosen.isEmpty())
return;
Set<Object> set = myModel.data.stream().map(o -> o.first).collect(Collectors.toSet());
for (VirtualFile file : chosen) {
if (!set.add(file))
continue;
myModel.data.add(Pair.create(file, null));
}
myModel.fireTableDataChanged();
TIntArrayList rowList = new TIntArrayList();
for (int i = 0, size = myModel.data.size(); i < size; i++) {
if (chosen.contains(myModel.data.get(i).first))
rowList.add(i);
}
selectRows(rowList.toNativeArray(), true);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class TestDiscoveryIndex method doUpdateFromTestTrace.
private void doUpdateFromTestTrace(File file, final String testName, @Nullable final String moduleName) throws IOException {
myLocalTestRunDataController.withTestDataHolder(new ThrowableConvertor<TestInfoHolder, Void, IOException>() {
@Override
public Void convert(TestInfoHolder localHolder) throws IOException {
final int testNameId = localHolder.myTestNameEnumerator.enumerate(testName);
TIntObjectHashMap<TIntArrayList> classData = loadClassAndMethodsMap(file, localHolder);
TIntObjectHashMap<TIntArrayList> previousClassData = localHolder.myTestNameToUsedClassesAndMethodMap.get(testNameId);
if (previousClassData == null) {
previousClassData = myRemoteTestRunDataController.withTestDataHolder(remoteDataHolder -> {
TIntObjectHashMap<TIntArrayList> remoteClassData = remoteDataHolder.myTestNameToUsedClassesAndMethodMap.get(testNameId);
if (remoteClassData == null)
return null;
TIntObjectHashMap<TIntArrayList> result = new TIntObjectHashMap<>(remoteClassData.size());
Ref<IOException> exceptionRef = new Ref<>();
boolean processingResult = remoteClassData.forEachEntry((remoteClassKey, remoteClassMethodIds) -> {
try {
int localClassKey = localHolder.myClassEnumeratorCache.enumerate(remoteDataHolder.myClassEnumeratorCache.valueOf(remoteClassKey));
TIntArrayList localClassIds = new TIntArrayList(remoteClassMethodIds.size());
for (int methodId : remoteClassMethodIds.toNativeArray()) {
localClassIds.add(localHolder.myMethodEnumeratorCache.enumerate(remoteDataHolder.myMethodEnumeratorCache.valueOf(methodId)));
}
result.put(localClassKey, localClassIds);
return true;
} catch (IOException ex) {
exceptionRef.set(ex);
return false;
}
});
if (!processingResult)
throw exceptionRef.get();
return result;
});
}
localHolder.doUpdateFromDiff(testNameId, classData, previousClassData, moduleName != null ? localHolder.myModuleNameEnumerator.enumerate(moduleName) : null);
return null;
}
});
}
use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.
the class MovieSymbolTranscoder method processDefineSprite.
private void processDefineSprite(PlacedObject placedObject) throws IOException {
buffer.position(placedObject.start + 4);
final int endPosition = placedObject.start + placedObject.length;
while (true) {
final int tagStart = buffer.position();
final int tagCodeAndLength = buffer.getShort();
final int type = tagCodeAndLength >> 6;
int length = tagCodeAndLength & 0x3F;
if (length == 63) {
length = buffer.getInt();
}
final int start = buffer.position();
switch(type) {
case TagTypes.DoAction:
case TagTypes.DoInitAction:
placedObject.prepareSparseWrite();
if (placedObject.positions == null) {
placedObject.positions = new TIntArrayList();
placedObject.actualLength = placedObject.length;
}
placedObject.positions.add(tagStart);
final int fullLength = length + (start - tagStart);
placedObject.positions.add(tagStart + fullLength);
placedObject.actualLength -= fullLength;
continue;
case TagTypes.PlaceObject:
case TagTypes.PlaceObject3:
throw new IOException("PlaceObject and PlaceObject3 are not supported");
case TagTypes.PlaceObject2:
processPlaceObject2(placedObject, length, start);
break;
}
final int newPosition = start + length;
if (newPosition < endPosition) {
buffer.position(newPosition);
} else {
break;
}
}
}
Aggregations