use of gnu.trove.TIntHashSet 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;
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class VcsLogPersistentIndex method markForIndexing.
@Override
public synchronized void markForIndexing(int index, @NotNull VirtualFile root) {
if (isIndexed(index) || !myRoots.contains(root))
return;
TIntHashSet set = myCommitsToIndex.get(root);
if (set == null) {
set = new TIntHashSet();
myCommitsToIndex.put(root, set);
}
set.add(index);
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class VcsLogPersistentIndex method filter.
@Override
@NotNull
public Set<Integer> filter(@NotNull List<VcsLogDetailsFilter> detailsFilters) {
VcsLogTextFilter textFilter = ContainerUtil.findInstance(detailsFilters, VcsLogTextFilter.class);
VcsLogUserFilter userFilter = ContainerUtil.findInstance(detailsFilters, VcsLogUserFilter.class);
VcsLogStructureFilter pathFilter = ContainerUtil.findInstance(detailsFilters, VcsLogStructureFilter.class);
TIntHashSet filteredByMessage = null;
if (textFilter != null) {
filteredByMessage = filterMessages(textFilter);
}
TIntHashSet filteredByUser = null;
if (userFilter != null) {
Set<VcsUser> users = ContainerUtil.newHashSet();
for (VirtualFile root : myRoots) {
users.addAll(userFilter.getUsers(root));
}
filteredByUser = filterUsers(users);
}
TIntHashSet filteredByPath = null;
if (pathFilter != null) {
filteredByPath = filterPaths(pathFilter.getFiles());
}
return TroveUtil.intersect(filteredByMessage, filteredByPath, filteredByUser);
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class DefinitionMap method copyFrom.
public void copyFrom(DefinitionMap map, int fromIndex, int toIndex) {
TIntHashSet defs = map.myMap.get(fromIndex);
if (defs == null)
defs = new TIntHashSet();
myMap.put(toIndex, defs);
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class UnusedDefInspection method check.
@Override
protected void check(@NotNull final GrControlFlowOwner owner, @NotNull final ProblemsHolder problemsHolder) {
final Instruction[] flow = owner.getControlFlow();
final ReachingDefinitionsDfaInstance dfaInstance = new ReachingDefinitionsDfaInstance(flow);
final ReachingDefinitionsSemilattice lattice = new ReachingDefinitionsSemilattice();
final DFAEngine<DefinitionMap> engine = new DFAEngine<>(flow, dfaInstance, lattice);
final List<DefinitionMap> dfaResult = engine.performDFAWithTimeout();
if (dfaResult == null) {
return;
}
final TIntHashSet unusedDefs = new TIntHashSet();
for (Instruction instruction : flow) {
if (instruction instanceof ReadWriteVariableInstruction && ((ReadWriteVariableInstruction) instruction).isWrite()) {
unusedDefs.add(instruction.num());
}
}
for (int i = 0; i < dfaResult.size(); i++) {
final Instruction instruction = flow[i];
if (instruction instanceof ReadWriteVariableInstruction) {
final ReadWriteVariableInstruction varInst = (ReadWriteVariableInstruction) instruction;
if (!varInst.isWrite()) {
final String varName = varInst.getVariableName();
DefinitionMap e = dfaResult.get(i);
e.forEachValue(new TObjectProcedure<TIntHashSet>() {
@Override
public boolean execute(TIntHashSet reaching) {
reaching.forEach(new TIntProcedure() {
@Override
public boolean execute(int defNum) {
final String defName = ((ReadWriteVariableInstruction) flow[defNum]).getVariableName();
if (varName.equals(defName)) {
unusedDefs.remove(defNum);
}
return true;
}
});
return true;
}
});
}
}
}
final Set<PsiElement> checked = ContainerUtil.newHashSet();
unusedDefs.forEach(new TIntProcedure() {
@Override
public boolean execute(int num) {
final ReadWriteVariableInstruction instruction = (ReadWriteVariableInstruction) flow[num];
final PsiElement element = instruction.getElement();
process(element, checked, problemsHolder, GroovyInspectionBundle.message("unused.assignment.tooltip"));
return true;
}
});
owner.accept(new GroovyRecursiveElementVisitor() {
@Override
public void visitVariable(@NotNull GrVariable variable) {
if (checked.contains(variable) || variable.getInitializerGroovy() != null)
return;
if (ReferencesSearch.search(variable, variable.getUseScope()).findFirst() == null) {
process(variable, checked, problemsHolder, GroovyInspectionBundle.message("unused.variable"));
}
}
});
}
Aggregations