Search in sources :

Example 11 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class RemoveArrangementRuleAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ArrangementMatchingRulesControl control = getRulesControl(e);
    if (control == null) {
        return;
    }
    control.hideEditor();
    final TIntArrayList rowsToRemove = control.getSelectedModelRows();
    if (rowsToRemove.isEmpty()) {
        return;
    }
    final ArrangementMatchingRulesModel model = control.getModel();
    control.runOperationIgnoreSelectionChange(() -> {
        for (int i = 0; i < rowsToRemove.size(); i++) {
            int row = rowsToRemove.get(i);
            model.removeRow(row);
        }
    });
}
Also used : ArrangementMatchingRulesModel(com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel) ArrangementMatchingRulesControl(com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl) TIntArrayList(gnu.trove.TIntArrayList)

Example 12 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class AddArrangementRuleAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ArrangementMatchingRulesControl control = getRulesControl(e);
    if (control == null) {
        return;
    }
    control.hideEditor();
    TIntArrayList rows = control.getSelectedModelRows();
    ArrangementMatchingRulesModel model = control.getModel();
    int rowToEdit;
    if (rows.size() == 1) {
        rowToEdit = rows.get(0) + 1;
        model.insertRow(rowToEdit, new Object[] { createNewRule(control) });
    } else {
        rowToEdit = model.getSize();
        model.add(createNewRule(control));
    }
    showEditor(control, rowToEdit);
    control.getSelectionModel().setSelectionInterval(rowToEdit, rowToEdit);
    scrollRowToVisible(control, rowToEdit);
}
Also used : ArrangementMatchingRulesModel(com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel) ArrangementMatchingRulesControl(com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl) TIntArrayList(gnu.trove.TIntArrayList)

Example 13 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class StubIndexImpl method getContainingIds.

@NotNull
@Override
public <Key> IdIterator getContainingIds(@NotNull StubIndexKey<Key, ?> indexKey, @NotNull Key dataKey, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
    final TIntArrayList result = new TIntArrayList();
    doProcessStubs(indexKey, dataKey, project, scope, new StubIdListContainerAction(null, project) {

        @Override
        protected boolean process(int id, StubIdList value) {
            result.add(id);
            return true;
        }
    });
    return new IdIterator() {

        int cursor;

        @Override
        public boolean hasNext() {
            return cursor < result.size();
        }

        @Override
        public int next() {
            return result.get(cursor++);
        }

        @Override
        public int size() {
            return result.size();
        }
    };
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class FileBasedIndexImpl method projectIndexableFiles.

@Nullable
public ProjectIndexableFilesFilter projectIndexableFiles(@Nullable Project project) {
    if (project == null || myUpdatingFiles.get() > 0)
        return null;
    if (myProjectsBeingUpdated.contains(project))
        return null;
    SoftReference<ProjectIndexableFilesFilter> reference = project.getUserData(ourProjectFilesSetKey);
    ProjectIndexableFilesFilter data = com.intellij.reference.SoftReference.dereference(reference);
    if (data != null && data.myModificationCount == myFilesModCount)
        return data;
    if (myCalcIndexableFilesLock.tryLock()) {
        // make best effort for calculating filter
        try {
            reference = project.getUserData(ourProjectFilesSetKey);
            data = com.intellij.reference.SoftReference.dereference(reference);
            if (data != null && data.myModificationCount == myFilesModCount) {
                return data;
            }
            long start = System.currentTimeMillis();
            final TIntArrayList filesSet = new TIntArrayList();
            iterateIndexableFiles(fileOrDir -> {
                ProgressManager.checkCanceled();
                filesSet.add(((VirtualFileWithId) fileOrDir).getId());
                return true;
            }, project, SilentProgressIndicator.create());
            ProjectIndexableFilesFilter filter = new ProjectIndexableFilesFilter(filesSet, myFilesModCount);
            project.putUserData(ourProjectFilesSetKey, new SoftReference<>(filter));
            long finish = System.currentTimeMillis();
            LOG.debug(filesSet.size() + " files iterated in " + (finish - start) + " ms");
            return filter;
        } finally {
            myCalcIndexableFilesLock.unlock();
        }
    }
    // ok, no filtering
    return null;
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class PerFileConfigurableBase method findRow.

protected int[] findRow(VirtualFile file, boolean strict, boolean all) {
    TIntArrayList rows = new TIntArrayList();
    List<Pair<Object, T>> reversed = ContainerUtil.reverse(myModel.data);
    for (int i = 0, size = reversed.size(); i < size; i++) {
        Pair<Object, T> p = reversed.get(i);
        if (keyMatches(p.first, file, strict)) {
            rows.add(size - i - 1);
            if (!all)
                break;
        }
    }
    return rows.toNativeArray();
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2