use of gnu.trove.TIntProcedure in project intellij-community by JetBrains.
the class InvertedIndexUtil method collectInputIdsContainingAllKeys.
@NotNull
public static <K, V, I> TIntHashSet collectInputIdsContainingAllKeys(@NotNull InvertedIndex<K, V, I> index, @NotNull Collection<K> dataKeys, @Nullable Condition<K> keyChecker, @Nullable Condition<V> valueChecker, @Nullable ValueContainer.IntPredicate idChecker) throws StorageException {
TIntHashSet mainIntersection = null;
for (K dataKey : dataKeys) {
if (keyChecker != null && !keyChecker.value(dataKey))
continue;
final TIntHashSet copy = new TIntHashSet();
final ValueContainer<V> container = index.getData(dataKey);
for (ValueContainer.ValueIterator<V> valueIt = container.getValueIterator(); valueIt.hasNext(); ) {
final V value = valueIt.next();
if (valueChecker != null && !valueChecker.value(value)) {
continue;
}
ValueContainer.IntIterator iterator = valueIt.getInputIdsIterator();
final ValueContainer.IntPredicate predicate;
if (mainIntersection == null || iterator.size() < mainIntersection.size() || (predicate = valueIt.getValueAssociationPredicate()) == null) {
while (iterator.hasNext()) {
final int id = iterator.next();
if (mainIntersection == null && (idChecker == null || idChecker.contains(id)) || mainIntersection != null && mainIntersection.contains(id)) {
copy.add(id);
}
}
} else {
mainIntersection.forEach(new TIntProcedure() {
@Override
public boolean execute(int id) {
if (predicate.contains(id))
copy.add(id);
return true;
}
});
}
}
mainIntersection = copy;
if (mainIntersection.isEmpty()) {
return EmptyIntHashSet.INSTANCE;
}
}
return mainIntersection == null ? EmptyIntHashSet.INSTANCE : mainIntersection;
}
use of gnu.trove.TIntProcedure in project intellij-community by JetBrains.
the class IntroduceParameterProcessor method removeParametersFromCall.
private void removeParametersFromCall(final PsiExpressionList argList) {
final PsiExpression[] exprs = argList.getExpressions();
myParametersToRemove.forEachDescending(new TIntProcedure() {
public boolean execute(final int paramNum) {
if (paramNum < exprs.length) {
try {
exprs[paramNum].delete();
} catch (IncorrectOperationException e) {
LOG.error(e);
}
}
return true;
}
});
}
use of gnu.trove.TIntProcedure in project intellij-community by JetBrains.
the class JavaIntroduceParameterMethodUsagesProcessor method findConflicts.
public void findConflicts(IntroduceParameterData data, UsageInfo[] usages, final MultiMap<PsiElement, String> conflicts) {
final PsiMethod method = data.getMethodToReplaceIn();
final int parametersCount = method.getParameterList().getParametersCount();
for (UsageInfo usage : usages) {
final PsiElement element = usage.getElement();
if (element instanceof PsiMethodReferenceExpression && !ApplicationManager.getApplication().isUnitTestMode()) {
conflicts.putValue(element, RefactoringBundle.message("expand.method.reference.warning"));
}
if (!isMethodUsage(usage))
continue;
final PsiCall call = RefactoringUtil.getCallExpressionByMethodReference(element);
final PsiExpressionList argList = call.getArgumentList();
if (argList != null) {
final int actualParamLength = argList.getExpressions().length;
if ((method.isVarArgs() && actualParamLength + 1 < parametersCount) || (!method.isVarArgs() && actualParamLength < parametersCount)) {
conflicts.putValue(call, "Incomplete call(" + call.getText() + "): " + parametersCount + " parameters expected but only " + actualParamLength + " found");
}
data.getParametersToRemove().forEach(new TIntProcedure() {
public boolean execute(int paramNum) {
if (paramNum >= actualParamLength) {
conflicts.putValue(call, "Incomplete call(" + call.getText() + "): expected to delete the " + paramNum + " parameter but only " + actualParamLength + " parameters found");
}
return true;
}
});
}
}
}
use of gnu.trove.TIntProcedure in project intellij-community by JetBrains.
the class LoopAnalyzer method calcInLoop.
static int[] calcInLoop(ControlFlow controlFlow) {
// loop[i] = loop number(strongly connected component number) of i-th instruction or 0 if outside loop
final int[] loop = new int[controlFlow.getInstructionCount()];
MyGraph graph = new MyGraph(controlFlow);
final DFSTBuilder<Instruction> builder = new DFSTBuilder<>(graph);
TIntArrayList sccs = builder.getSCCs();
sccs.forEach(new TIntProcedure() {
private int myTNumber;
private int component;
@Override
public boolean execute(int size) {
int value = size > 1 ? ++component : 0;
for (int i = 0; i < size; i++) {
Instruction instruction = builder.getNodeByTNumber(myTNumber + i);
loop[instruction.getIndex()] = value;
}
myTNumber += size;
return true;
}
});
return loop;
}
use of gnu.trove.TIntProcedure in project intellij-community by JetBrains.
the class EqClass method getMemberValues.
List<DfaValue> getMemberValues() {
final List<DfaValue> result = new ArrayList<>(size());
forEach(new TIntProcedure() {
@Override
public boolean execute(int c1) {
DfaValue value = myFactory.getValue(c1);
result.add(value);
return true;
}
});
return result;
}
Aggregations