Search in sources :

Example 56 with THashSet

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

the class ConsoleViewImplTest method backspace.

private static void backspace(ConsoleViewImpl consoleView) {
    Editor editor = consoleView.getEditor();
    Set<Shortcut> backShortcuts = new THashSet<>(Arrays.asList(ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_BACKSPACE).getShortcutSet().getShortcuts()));
    List<AnAction> actions = ActionUtil.getActions(consoleView.getEditor().getContentComponent());
    AnAction handler = actions.stream().filter(a -> new THashSet<>(Arrays.asList(a.getShortcutSet().getShortcuts())).equals(backShortcuts)).findFirst().get();
    CommandProcessor.getInstance().executeCommand(getProject(), () -> EditorTestUtil.executeAction(editor, true, handler), "", null, editor.getDocument());
}
Also used : Editor(com.intellij.openapi.editor.Editor) THashSet(gnu.trove.THashSet)

Example 57 with THashSet

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

the class ModuleManagerImpl method loadModules.

protected void loadModules(@NotNull ModuleModelImpl moduleModel) {
    myFailedModulePaths.clear();
    if (myModulePathsToLoad == null || myModulePathsToLoad.isEmpty()) {
        return;
    }
    myFailedModulePaths.addAll(myModulePathsToLoad);
    ProgressIndicator globalIndicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
    ProgressIndicator progressIndicator = myProject.isDefault() || globalIndicator == null ? new EmptyProgressIndicator() : globalIndicator;
    progressIndicator.setText("Loading modules...");
    progressIndicator.setText2("");
    List<Module> modulesWithUnknownTypes = new SmartList<>();
    List<ModuleLoadingErrorDescription> errors = Collections.synchronizedList(new ArrayList<>());
    ModuleGroupInterner groupInterner = new ModuleGroupInterner();
    ExecutorService service = AppExecutorUtil.createBoundedApplicationPoolExecutor("modules loader", JobSchedulerImpl.CORES_COUNT);
    List<Pair<Future<Module>, ModulePath>> tasks = new ArrayList<>();
    Set<String> paths = new THashSet<>();
    boolean parallel = Registry.is("parallel.modules.loading");
    for (ModulePath modulePath : myModulePathsToLoad) {
        if (progressIndicator.isCanceled()) {
            break;
        }
        try {
            String path = modulePath.getPath();
            if (!paths.add(path))
                continue;
            if (!parallel) {
                tasks.add(Pair.create(null, modulePath));
                continue;
            }
            ThrowableComputable<Module, IOException> computable = moduleModel.loadModuleInternal(path);
            Future<Module> future = service.submit(() -> {
                progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
                try {
                    return computable.compute();
                } catch (IOException e) {
                    reportError(errors, modulePath, e);
                } catch (Exception e) {
                    LOG.error(e);
                }
                return null;
            });
            tasks.add(Pair.create(future, modulePath));
        } catch (IOException e) {
            reportError(errors, modulePath, e);
        }
    }
    for (Pair<Future<Module>, ModulePath> task : tasks) {
        if (progressIndicator.isCanceled()) {
            break;
        }
        try {
            Module module;
            if (parallel) {
                module = task.first.get();
            } else {
                module = moduleModel.loadModuleInternal(task.second.getPath()).compute();
                progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
            }
            if (module == null)
                continue;
            if (isUnknownModuleType(module)) {
                modulesWithUnknownTypes.add(module);
            }
            ModulePath modulePath = task.second;
            final String groupPathString = modulePath.getGroup();
            if (groupPathString != null) {
                // model should be updated too
                groupInterner.setModuleGroupPath(moduleModel, module, groupPathString.split(MODULE_GROUP_SEPARATOR));
            }
            myFailedModulePaths.remove(modulePath);
        } catch (IOException e) {
            reportError(errors, task.second, e);
        } catch (Exception e) {
            LOG.error(e);
        }
    }
    service.shutdown();
    progressIndicator.checkCanceled();
    Application app = ApplicationManager.getApplication();
    if (app.isInternal() || app.isEAP() || ApplicationInfo.getInstance().getBuild().isSnapshot()) {
        Map<String, Module> track = new THashMap<>();
        for (Module module : moduleModel.getModules()) {
            for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
                Module oldModule = track.put(url, module);
                if (oldModule != null) {
                    //Map<String, VirtualFilePointer> track1 = ContentEntryImpl.track;
                    //VirtualFilePointer pointer = track1.get(url);
                    LOG.error("duplicated content url: " + url);
                }
            }
        }
    }
    onModuleLoadErrors(moduleModel, errors);
    showUnknownModuleTypeNotification(modulesWithUnknownTypes);
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) THashMap(gnu.trove.THashMap) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) IOException(java.io.IOException) THashSet(gnu.trove.THashSet) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) SmartList(com.intellij.util.SmartList) Application(com.intellij.openapi.application.Application)

Example 58 with THashSet

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

the class DartProjectComponent method collectFolderUrlsToExclude.

private static Set<String> collectFolderUrlsToExclude(@NotNull final Module module, @NotNull final VirtualFile pubspecYamlFile) {
    final THashSet<String> newExcludedPackagesUrls = new THashSet<>();
    final VirtualFile root = pubspecYamlFile.getParent();
    newExcludedPackagesUrls.add(root.getUrl() + "/.pub");
    newExcludedPackagesUrls.add(root.getUrl() + "/build");
    newExcludedPackagesUrls.addAll(getExcludedPackageSymlinkUrls(module.getProject(), root));
    return newExcludedPackagesUrls;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet)

Example 59 with THashSet

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

the class DartIndexUtil method processImportOrExportStatement.

private static void processImportOrExportStatement(@NotNull final DartFileIndexData result, @NotNull final DartImportOrExportStatement importOrExportStatement) {
    final String uri = importOrExportStatement.getUriString();
    final Set<String> showComponentNames = new THashSet<>();
    for (DartShowCombinator showCombinator : importOrExportStatement.getShowCombinatorList()) {
        final DartLibraryReferenceList libraryReferenceList = showCombinator.getLibraryReferenceList();
        if (libraryReferenceList != null) {
            for (DartExpression expression : libraryReferenceList.getLibraryComponentReferenceExpressionList()) {
                showComponentNames.add(expression.getText());
            }
        }
    }
    final Set<String> hideComponentNames = new THashSet<>();
    for (DartHideCombinator hideCombinator : importOrExportStatement.getHideCombinatorList()) {
        final DartLibraryReferenceList libraryReferenceList = hideCombinator.getLibraryReferenceList();
        if (libraryReferenceList != null) {
            for (DartExpression expression : libraryReferenceList.getLibraryComponentReferenceExpressionList()) {
                hideComponentNames.add(expression.getText());
            }
        }
    }
    final DartComponentName importPrefixComponent = importOrExportStatement instanceof DartImportStatement ? ((DartImportStatement) importOrExportStatement).getImportPrefix() : null;
    final String importPrefix = importPrefixComponent != null ? importPrefixComponent.getName() : null;
    final Kind kind = importOrExportStatement instanceof DartImportStatement ? Kind.Import : Kind.Export;
    result.addImportInfo(new DartImportOrExportInfo(kind, uri, importPrefix, showComponentNames, hideComponentNames));
    result.addComponentInfo(importPrefix, new DartComponentInfo(DartComponentType.LABEL, null));
}
Also used : Kind(com.jetbrains.lang.dart.ide.index.DartImportOrExportInfo.Kind) THashSet(gnu.trove.THashSet)

Example 60 with THashSet

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

the class DartSymbolIndex method getItemsByName.

public static List<DartComponentName> getItemsByName(@NotNull final String name, @NotNull final Project project, @NotNull final GlobalSearchScope searchScope) {
    final Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(DART_SYMBOL_INDEX, name, searchScope);
    final Set<DartComponentName> result = new THashSet<>();
    for (VirtualFile vFile : files) {
        final PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
        for (PsiElement root : DartResolveUtil.findDartRoots(psiFile)) {
            processComponents(root, component -> {
                if (name.equals(component.getName())) {
                    result.add(component.getComponentName());
                }
                return true;
            });
        }
    }
    return new ArrayList<>(result);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) THashSet(gnu.trove.THashSet) PsiElement(com.intellij.psi.PsiElement)

Aggregations

THashSet (gnu.trove.THashSet)239 NotNull (org.jetbrains.annotations.NotNull)65 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 Project (com.intellij.openapi.project.Project)35 File (java.io.File)35 THashMap (gnu.trove.THashMap)31 Nullable (org.jetbrains.annotations.Nullable)31 Module (com.intellij.openapi.module.Module)29 IOException (java.io.IOException)24 PsiElement (com.intellij.psi.PsiElement)21 PsiFile (com.intellij.psi.PsiFile)18 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)16 java.util (java.util)16 Element (org.jdom.Element)14 Pair (com.intellij.openapi.util.Pair)13 Logger (com.intellij.openapi.diagnostic.Logger)12 ContainerUtil (com.intellij.util.containers.ContainerUtil)12 Document (com.intellij.openapi.editor.Document)11 Library (com.intellij.openapi.roots.libraries.Library)11 StringUtil (com.intellij.openapi.util.text.StringUtil)10