Search in sources :

Example 1 with TIntHashSet

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);
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) TIntHashSet(gnu.trove.TIntHashSet)

Example 2 with TIntHashSet

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;
}
Also used : LightRef(org.jetbrains.jps.backwardRefs.LightRef) TIntHashSet(gnu.trove.TIntHashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with TIntHashSet

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();
    }
}
Also used : DirtyScopeTestInfo(com.intellij.compiler.backwardRefs.view.DirtyScopeTestInfo) CompilerReferenceFindUsagesTestInfo(com.intellij.compiler.backwardRefs.view.CompilerReferenceFindUsagesTestInfo) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with TIntHashSet

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();
    }
}
Also used : LightRef(org.jetbrains.jps.backwardRefs.LightRef) StorageException(com.intellij.util.indexing.StorageException) TIntHashSet(gnu.trove.TIntHashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with TIntHashSet

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();
                }
            };
        }
    };
}
Also used : Iterator(java.util.Iterator) ChangeSet(com.intellij.history.core.changes.ChangeSet) TIntHashSet(gnu.trove.TIntHashSet)

Aggregations

TIntHashSet (gnu.trove.TIntHashSet)50 NotNull (org.jetbrains.annotations.NotNull)16 TIntArrayList (gnu.trove.TIntArrayList)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 IOException (java.io.IOException)4 Nullable (org.jetbrains.annotations.Nullable)4 TIntProcedure (gnu.trove.TIntProcedure)3 ArrayList (java.util.ArrayList)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Processor (com.intellij.util.Processor)2 StorageException (com.intellij.util.indexing.StorageException)2 CharArrayCharSequence (com.intellij.util.text.CharArrayCharSequence)2 THashSet (gnu.trove.THashSet)2 TIntIterator (gnu.trove.TIntIterator)2 LightRef (org.jetbrains.jps.backwardRefs.LightRef)2 GenerateMembersUtil (com.intellij.codeInsight.generation.GenerateMembersUtil)1 Edge (com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge)1 CompilerReferenceFindUsagesTestInfo (com.intellij.compiler.backwardRefs.view.CompilerReferenceFindUsagesTestInfo)1 DirtyScopeTestInfo (com.intellij.compiler.backwardRefs.view.DirtyScopeTestInfo)1 PluginException (com.intellij.diagnostic.PluginException)1