Search in sources :

Example 16 with TIntArrayList

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

the class PerFileConfigurableBase method doAddFiles.

private void doAddFiles(@NotNull List<VirtualFile> files) {
    Set<VirtualFile> chosen = ContainerUtil.newHashSet(files);
    if (chosen.isEmpty())
        return;
    Set<Object> set = myModel.data.stream().map(o -> o.first).collect(Collectors.toSet());
    for (VirtualFile file : chosen) {
        if (!set.add(file))
            continue;
        myModel.data.add(Pair.create(file, null));
    }
    myModel.fireTableDataChanged();
    TIntArrayList rowList = new TIntArrayList();
    for (int i = 0, size = myModel.data.size(); i < size; i++) {
        if (chosen.contains(myModel.data.get(i).first))
            rowList.add(i);
    }
    selectRows(rowList.toNativeArray(), true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) com.intellij.openapi.util(com.intellij.openapi.util) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) javax.swing.table(javax.swing.table) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) PerFileMappingsBase(com.intellij.lang.PerFileMappingsBase) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JBUI(com.intellij.util.ui.JBUI) Project(com.intellij.openapi.project.Project) SpeedSearchUtil(com.intellij.ui.speedSearch.SpeedSearchUtil) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Messages(com.intellij.openapi.ui.Messages) PerFileMappings(com.intellij.lang.PerFileMappings) FileUtil(com.intellij.openapi.util.io.FileUtil) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) TIntArrayList(gnu.trove.TIntArrayList) CustomComponentAction(com.intellij.openapi.actionSystem.ex.CustomComponentAction) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) Configurable(com.intellij.openapi.options.Configurable) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) JBPopup(com.intellij.openapi.ui.popup.JBPopup) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ConfigurationException(com.intellij.openapi.options.ConfigurationException) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FileChooser(com.intellij.openapi.fileChooser.FileChooser) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) TIntArrayList(gnu.trove.TIntArrayList)

Example 17 with TIntArrayList

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

the class TestDiscoveryIndex method doUpdateFromTestTrace.

private void doUpdateFromTestTrace(File file, final String testName, @Nullable final String moduleName) throws IOException {
    myLocalTestRunDataController.withTestDataHolder(new ThrowableConvertor<TestInfoHolder, Void, IOException>() {

        @Override
        public Void convert(TestInfoHolder localHolder) throws IOException {
            final int testNameId = localHolder.myTestNameEnumerator.enumerate(testName);
            TIntObjectHashMap<TIntArrayList> classData = loadClassAndMethodsMap(file, localHolder);
            TIntObjectHashMap<TIntArrayList> previousClassData = localHolder.myTestNameToUsedClassesAndMethodMap.get(testNameId);
            if (previousClassData == null) {
                previousClassData = myRemoteTestRunDataController.withTestDataHolder(remoteDataHolder -> {
                    TIntObjectHashMap<TIntArrayList> remoteClassData = remoteDataHolder.myTestNameToUsedClassesAndMethodMap.get(testNameId);
                    if (remoteClassData == null)
                        return null;
                    TIntObjectHashMap<TIntArrayList> result = new TIntObjectHashMap<>(remoteClassData.size());
                    Ref<IOException> exceptionRef = new Ref<>();
                    boolean processingResult = remoteClassData.forEachEntry((remoteClassKey, remoteClassMethodIds) -> {
                        try {
                            int localClassKey = localHolder.myClassEnumeratorCache.enumerate(remoteDataHolder.myClassEnumeratorCache.valueOf(remoteClassKey));
                            TIntArrayList localClassIds = new TIntArrayList(remoteClassMethodIds.size());
                            for (int methodId : remoteClassMethodIds.toNativeArray()) {
                                localClassIds.add(localHolder.myMethodEnumeratorCache.enumerate(remoteDataHolder.myMethodEnumeratorCache.valueOf(methodId)));
                            }
                            result.put(localClassKey, localClassIds);
                            return true;
                        } catch (IOException ex) {
                            exceptionRef.set(ex);
                            return false;
                        }
                    });
                    if (!processingResult)
                        throw exceptionRef.get();
                    return result;
                });
            }
            localHolder.doUpdateFromDiff(testNameId, classData, previousClassData, moduleName != null ? localHolder.myModuleNameEnumerator.enumerate(moduleName) : null);
            return null;
        }
    });
}
Also used : Ref(com.intellij.openapi.util.Ref) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) TIntArrayList(gnu.trove.TIntArrayList)

Example 18 with TIntArrayList

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

the class SmartIntToIntArrayMap method removeFromMultiMap.

private void removeFromMultiMap(int key, int value) {
    final TIntObjectHashMap<TIntArrayList> map = myMultipleValuesMap;
    if (map == null)
        return;
    TIntArrayList list = map.get(key);
    if (list != null) {
        int offset = list.indexOf(value);
        if (offset != -1) {
            list.remove(offset);
            if (list.isEmpty()) {
                map.remove(key);
            }
        }
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 19 with TIntArrayList

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

the class ResolverTree method reduceCyclicVariables.

private void reduceCyclicVariables() {
    final Set<PsiTypeVariable> nodes = new HashSet<>();
    final Set<Constraint> candidates = new HashSet<>();
    final Map<PsiTypeVariable, Set<PsiTypeVariable>> ins = new HashMap<>();
    final Map<PsiTypeVariable, Set<PsiTypeVariable>> outs = new HashMap<>();
    for (final Constraint constraint : myConstraints) {
        final PsiType left = constraint.getLeft();
        final PsiType right = constraint.getRight();
        if (left instanceof PsiTypeVariable && right instanceof PsiTypeVariable) {
            final PsiTypeVariable leftVar = (PsiTypeVariable) left;
            final PsiTypeVariable rightVar = (PsiTypeVariable) right;
            candidates.add(constraint);
            nodes.add(leftVar);
            nodes.add(rightVar);
            Set<PsiTypeVariable> in = ins.get(leftVar);
            Set<PsiTypeVariable> out = outs.get(rightVar);
            if (in == null) {
                final Set<PsiTypeVariable> newIn = new HashSet<>();
                newIn.add(rightVar);
                ins.put(leftVar, newIn);
            } else {
                in.add(rightVar);
            }
            if (out == null) {
                final Set<PsiTypeVariable> newOut = new HashSet<>();
                newOut.add(leftVar);
                outs.put(rightVar, newOut);
            } else {
                out.add(leftVar);
            }
        }
    }
    final DFSTBuilder<PsiTypeVariable> dfstBuilder = new DFSTBuilder<>(new Graph<PsiTypeVariable>() {

        @Override
        public Collection<PsiTypeVariable> getNodes() {
            return nodes;
        }

        @Override
        public Iterator<PsiTypeVariable> getIn(final PsiTypeVariable n) {
            final Set<PsiTypeVariable> in = ins.get(n);
            if (in == null) {
                return EmptyIterator.getInstance();
            }
            return in.iterator();
        }

        @Override
        public Iterator<PsiTypeVariable> getOut(final PsiTypeVariable n) {
            final Set<PsiTypeVariable> out = outs.get(n);
            if (out == null) {
                return EmptyIterator.getInstance();
            }
            return out.iterator();
        }
    });
    final TIntArrayList sccs = dfstBuilder.getSCCs();
    final Map<PsiTypeVariable, Integer> index = new HashMap<>();
    sccs.forEach(new TIntProcedure() {

        int myTNumber;

        @Override
        public boolean execute(int size) {
            for (int j = 0; j < size; j++) {
                index.put(dfstBuilder.getNodeByTNumber(myTNumber + j), myTNumber);
            }
            myTNumber += size;
            return true;
        }
    });
    for (final Constraint constraint : candidates) {
        if (index.get(constraint.getLeft()).equals(index.get(constraint.getRight()))) {
            myConstraints.remove(constraint);
        }
    }
    Binding binding = myBindingFactory.create();
    for (final PsiTypeVariable fromVar : index.keySet()) {
        final PsiTypeVariable toVar = dfstBuilder.getNodeByNNumber(index.get(fromVar).intValue());
        if (!fromVar.equals(toVar)) {
            binding = binding.compose(myBindingFactory.create(fromVar, toVar));
            if (binding == null) {
                break;
            }
        }
    }
    if (binding != null && binding.nonEmpty()) {
        myCurrentBinding = myCurrentBinding.compose(binding);
        myConstraints = apply(binding);
    }
}
Also used : TIntProcedure(gnu.trove.TIntProcedure) Constraint(com.intellij.refactoring.typeCook.deductive.builder.Constraint) TObjectIntHashMap(gnu.trove.TObjectIntHashMap) TIntArrayList(gnu.trove.TIntArrayList) Constraint(com.intellij.refactoring.typeCook.deductive.builder.Constraint) EmptyIterator(com.intellij.util.containers.EmptyIterator) DFSTBuilder(com.intellij.util.graph.DFSTBuilder)

Example 20 with TIntArrayList

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

the class LineOffsets method create.

@NotNull
public static LineOffsets create(@NotNull CharSequence text) {
    TIntArrayList ends = new TIntArrayList();
    int index = 0;
    while (true) {
        int lineEnd = StringUtil.indexOf(text, '\n', index);
        if (lineEnd != -1) {
            ends.add(lineEnd);
            index = lineEnd + 1;
        } else {
            ends.add(text.length());
            break;
        }
    }
    return new LineOffsets(ends.toNativeArray(), text.length());
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

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