use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class DuplicateComponentsAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
FormEditingUtil.remapToActionTargets(selection);
RadContainer parent = FormEditingUtil.getSelectionParent(selection);
assert parent != null;
List<RadComponent> duplicates = new ArrayList<>();
Map<RadComponent, RadComponent> duplicateMap = new HashMap<>();
TIntHashSet insertedRows = new TIntHashSet();
boolean incrementRow = true;
if (selection.size() > 1 && canDuplicate(selection, false) && FormEditingUtil.getSelectionBounds(selection).width == 1) {
incrementRow = false;
}
for (RadComponent c : selection) {
final int row = c.getConstraints().getCell(incrementRow);
int rowSpan = c.getConstraints().getSpan(incrementRow);
int insertIndex = parent.indexOfComponent(c);
if (parent.getLayoutManager().isGrid()) {
if (!insertedRows.contains(row) && !isSpaceBelowEmpty(c, incrementRow)) {
insertedRows.add(row);
parent.getGridLayoutManager().copyGridCells(parent, parent, incrementRow, row, rowSpan, row + rowSpan);
}
}
List<RadComponent> copyList = CutCopyPasteSupport.copyComponents(editor, Collections.singletonList(c));
if (copyList != null) {
RadComponent copy = copyList.get(0);
if (parent.getLayoutManager().isGrid()) {
copy.getConstraints().setCell(incrementRow, row + rowSpan + parent.getGridLayoutManager().getGapCellCount());
copy.getConstraints().setSpan(incrementRow, rowSpan);
}
parent.addComponent(copy, insertIndex + 1);
fillDuplicateMap(duplicateMap, c, copy);
duplicates.add(copy);
}
}
adjustDuplicates(duplicateMap);
FormEditingUtil.selectComponents(editor, duplicates);
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class CompilerReferenceReader method findReferentFileIds.
@Nullable
TIntHashSet findReferentFileIds(@NotNull LightRef ref, boolean checkBaseClassAmbiguity) throws StorageException {
LightRef.LightClassHierarchyElementDef hierarchyElement = ref instanceof LightRef.LightClassHierarchyElementDef ? (LightRef.LightClassHierarchyElementDef) ref : ((LightRef.LightMember) ref).getOwner();
TIntHashSet set = new TIntHashSet();
final LightRef.NamedLightRef[] hierarchy = getWholeHierarchy(hierarchyElement, checkBaseClassAmbiguity);
if (hierarchy == null)
return null;
for (LightRef.NamedLightRef aClass : hierarchy) {
final LightRef overriderUsage = ref.override(aClass.getName());
addUsages(overriderUsage, set);
}
return set;
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class CompilerReferenceServiceImpl method getTestFindUsages.
@NotNull
public CompilerReferenceFindUsagesTestInfo getTestFindUsages(@NotNull PsiElement element) {
myReadDataLock.lock();
try {
final TIntHashSet referentFileIds = getReferentFileIds(element);
final DirtyScopeTestInfo dirtyScopeInfo = myDirtyScopeHolder.getState();
return new CompilerReferenceFindUsagesTestInfo(referentFileIds, dirtyScopeInfo, myProject);
} finally {
myReadDataLock.unlock();
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class CompilerReferenceServiceImpl method getReferentFileIds.
@Nullable
private TIntHashSet getReferentFileIds(@NotNull PsiElement element) {
final CompilerElementInfo compilerElementInfo = asCompilerElements(element, true);
if (compilerElementInfo == null)
return null;
myReadDataLock.lock();
try {
if (myReader == null)
return null;
TIntHashSet referentFileIds = new TIntHashSet();
for (LightRef ref : compilerElementInfo.searchElements) {
try {
final TIntHashSet referents = myReader.findReferentFileIds(ref, compilerElementInfo.place == ElementPlace.SRC);
if (referents == null)
return null;
referentFileIds.addAll(referents.toArray());
} catch (StorageException e) {
throw new RuntimeException(e);
}
}
return referentFileIds;
} finally {
myReadDataLock.unlock();
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class ChangeList method iterChanges.
// todo synchronization issue: changeset may me modified while being iterated
public synchronized Iterable<ChangeSet> iterChanges() {
return new Iterable<ChangeSet>() {
public Iterator<ChangeSet> iterator() {
return new Iterator<ChangeSet>() {
private final TIntHashSet recursionGuard = new TIntHashSet(1000);
private ChangeSetHolder currentBlock;
private ChangeSet next = fetchNext();
public boolean hasNext() {
return next != null;
}
public ChangeSet next() {
ChangeSet result = next;
next = fetchNext();
return result;
}
private ChangeSet fetchNext() {
if (currentBlock == null) {
synchronized (ChangeList.this) {
if (myCurrentChangeSet != null) {
currentBlock = new ChangeSetHolder(-1, myCurrentChangeSet);
} else {
currentBlock = myStorage.readPrevious(-1, recursionGuard);
}
}
} else {
synchronized (ChangeList.this) {
currentBlock = myStorage.readPrevious(currentBlock.id, recursionGuard);
}
}
if (currentBlock == null)
return null;
return currentBlock.changeSet;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
Aggregations