use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class RemoveArrangementRuleAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ArrangementMatchingRulesControl control = getRulesControl(e);
if (control == null) {
return;
}
control.hideEditor();
final TIntArrayList rowsToRemove = control.getSelectedModelRows();
if (rowsToRemove.isEmpty()) {
return;
}
final ArrangementMatchingRulesModel model = control.getModel();
control.runOperationIgnoreSelectionChange(() -> {
for (int i = 0; i < rowsToRemove.size(); i++) {
int row = rowsToRemove.get(i);
model.removeRow(row);
}
});
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class AddArrangementRuleAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
ArrangementMatchingRulesControl control = getRulesControl(e);
if (control == null) {
return;
}
control.hideEditor();
TIntArrayList rows = control.getSelectedModelRows();
ArrangementMatchingRulesModel model = control.getModel();
int rowToEdit;
if (rows.size() == 1) {
rowToEdit = rows.get(0) + 1;
model.insertRow(rowToEdit, new Object[] { createNewRule(control) });
} else {
rowToEdit = model.getSize();
model.add(createNewRule(control));
}
showEditor(control, rowToEdit);
control.getSelectionModel().setSelectionInterval(rowToEdit, rowToEdit);
scrollRowToVisible(control, rowToEdit);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class StubIndexImpl method getContainingIds.
@NotNull
@Override
public <Key> IdIterator getContainingIds(@NotNull StubIndexKey<Key, ?> indexKey, @NotNull Key dataKey, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
final TIntArrayList result = new TIntArrayList();
doProcessStubs(indexKey, dataKey, project, scope, new StubIdListContainerAction(null, project) {
@Override
protected boolean process(int id, StubIdList value) {
result.add(id);
return true;
}
});
return new IdIterator() {
int cursor;
@Override
public boolean hasNext() {
return cursor < result.size();
}
@Override
public int next() {
return result.get(cursor++);
}
@Override
public int size() {
return result.size();
}
};
}
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();
}
Aggregations