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-community by JetBrains.
the class SmartIntToIntArrayMap method removeFromMultiMap.
private void removeFromMultiMap(int key, int value) {
final TIntObjectHashMap<TIntArrayList> map = myMultipleValuesMap;
if (map == null)
return;
TIntArrayList list = map.get(key);
if (list != null) {
int offset = list.indexOf(value);
if (offset != -1) {
list.remove(offset);
if (list.isEmpty()) {
map.remove(key);
}
}
}
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class ResolverTree method reduceCyclicVariables.
private void reduceCyclicVariables() {
final Set<PsiTypeVariable> nodes = new HashSet<>();
final Set<Constraint> candidates = new HashSet<>();
final Map<PsiTypeVariable, Set<PsiTypeVariable>> ins = new HashMap<>();
final Map<PsiTypeVariable, Set<PsiTypeVariable>> outs = new HashMap<>();
for (final Constraint constraint : myConstraints) {
final PsiType left = constraint.getLeft();
final PsiType right = constraint.getRight();
if (left instanceof PsiTypeVariable && right instanceof PsiTypeVariable) {
final PsiTypeVariable leftVar = (PsiTypeVariable) left;
final PsiTypeVariable rightVar = (PsiTypeVariable) right;
candidates.add(constraint);
nodes.add(leftVar);
nodes.add(rightVar);
Set<PsiTypeVariable> in = ins.get(leftVar);
Set<PsiTypeVariable> out = outs.get(rightVar);
if (in == null) {
final Set<PsiTypeVariable> newIn = new HashSet<>();
newIn.add(rightVar);
ins.put(leftVar, newIn);
} else {
in.add(rightVar);
}
if (out == null) {
final Set<PsiTypeVariable> newOut = new HashSet<>();
newOut.add(leftVar);
outs.put(rightVar, newOut);
} else {
out.add(leftVar);
}
}
}
final DFSTBuilder<PsiTypeVariable> dfstBuilder = new DFSTBuilder<>(new Graph<PsiTypeVariable>() {
@Override
public Collection<PsiTypeVariable> getNodes() {
return nodes;
}
@Override
public Iterator<PsiTypeVariable> getIn(final PsiTypeVariable n) {
final Set<PsiTypeVariable> in = ins.get(n);
if (in == null) {
return EmptyIterator.getInstance();
}
return in.iterator();
}
@Override
public Iterator<PsiTypeVariable> getOut(final PsiTypeVariable n) {
final Set<PsiTypeVariable> out = outs.get(n);
if (out == null) {
return EmptyIterator.getInstance();
}
return out.iterator();
}
});
final TIntArrayList sccs = dfstBuilder.getSCCs();
final Map<PsiTypeVariable, Integer> index = new HashMap<>();
sccs.forEach(new TIntProcedure() {
int myTNumber;
@Override
public boolean execute(int size) {
for (int j = 0; j < size; j++) {
index.put(dfstBuilder.getNodeByTNumber(myTNumber + j), myTNumber);
}
myTNumber += size;
return true;
}
});
for (final Constraint constraint : candidates) {
if (index.get(constraint.getLeft()).equals(index.get(constraint.getRight()))) {
myConstraints.remove(constraint);
}
}
Binding binding = myBindingFactory.create();
for (final PsiTypeVariable fromVar : index.keySet()) {
final PsiTypeVariable toVar = dfstBuilder.getNodeByNNumber(index.get(fromVar).intValue());
if (!fromVar.equals(toVar)) {
binding = binding.compose(myBindingFactory.create(fromVar, toVar));
if (binding == null) {
break;
}
}
}
if (binding != null && binding.nonEmpty()) {
myCurrentBinding = myCurrentBinding.compose(binding);
myConstraints = apply(binding);
}
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class LineOffsets method create.
@NotNull
public static LineOffsets create(@NotNull CharSequence text) {
TIntArrayList ends = new TIntArrayList();
int index = 0;
while (true) {
int lineEnd = StringUtil.indexOf(text, '\n', index);
if (lineEnd != -1) {
ends.add(lineEnd);
index = lineEnd + 1;
} else {
ends.add(text.length());
break;
}
}
return new LineOffsets(ends.toNativeArray(), text.length());
}
Aggregations