Search in sources :

Example 41 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 42 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)

Example 43 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 44 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 45 with TIntArrayList

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

the class MovieSymbolTranscoder method processDefineSprite.

private void processDefineSprite(PlacedObject placedObject) throws IOException {
    buffer.position(placedObject.start + 4);
    final int endPosition = placedObject.start + placedObject.length;
    while (true) {
        final int tagStart = buffer.position();
        final int tagCodeAndLength = buffer.getShort();
        final int type = tagCodeAndLength >> 6;
        int length = tagCodeAndLength & 0x3F;
        if (length == 63) {
            length = buffer.getInt();
        }
        final int start = buffer.position();
        switch(type) {
            case TagTypes.DoAction:
            case TagTypes.DoInitAction:
                placedObject.prepareSparseWrite();
                if (placedObject.positions == null) {
                    placedObject.positions = new TIntArrayList();
                    placedObject.actualLength = placedObject.length;
                }
                placedObject.positions.add(tagStart);
                final int fullLength = length + (start - tagStart);
                placedObject.positions.add(tagStart + fullLength);
                placedObject.actualLength -= fullLength;
                continue;
            case TagTypes.PlaceObject:
            case TagTypes.PlaceObject3:
                throw new IOException("PlaceObject and PlaceObject3 are not supported");
            case TagTypes.PlaceObject2:
                processPlaceObject2(placedObject, length, start);
                break;
        }
        final int newPosition = start + length;
        if (newPosition < endPosition) {
            buffer.position(newPosition);
        } else {
            break;
        }
    }
}
Also used : IOException(java.io.IOException) 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