Search in sources :

Example 1 with THashSet

use of gnu.trove.THashSet in project intellij-elixir by KronicDeth.

the class Exports method from.

/*
     * Static Methods
     */
@Nullable
public static Exports from(@NotNull Chunk chunk) {
    Exports exports = null;
    if (chunk.typeID.equals(EXPT.toString()) && chunk.data.length >= 4) {
        Collection<Export> exportCollection = new THashSet<Export>();
        int offset = 0;
        Pair<Long, Integer> exportCountByteCount = unsignedInt(chunk.data, 0);
        long exportCount = exportCountByteCount.first;
        offset += exportCountByteCount.second;
        for (long i = 0; i < exportCount; i++) {
            Pair<Long, Integer> atomIndexByteCount = unsignedInt(chunk.data, offset);
            long atomIndex = atomIndexByteCount.first;
            offset += atomIndexByteCount.second;
            Pair<Long, Integer> arityByteCount = unsignedInt(chunk.data, offset);
            long arity = arityByteCount.first;
            offset += arityByteCount.second;
            // label is currently unused, but it must be consumed to read the next export at the correct offset
            Pair<Long, Integer> labelByteCount = unsignedInt(chunk.data, offset);
            offset += labelByteCount.second;
            exportCollection.add(new Export(atomIndex, arity));
        }
        exports = new Exports(exportCollection);
    }
    return exports;
}
Also used : Export(org.elixir_lang.beam.chunk.exports.Export) THashSet(gnu.trove.THashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with THashSet

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

the class MavenModuleImporter method configDependencies.

private void configDependencies() {
    THashSet<String> dependencyTypesFromSettings = new THashSet<>();
    AccessToken accessToken = ReadAction.start();
    try {
        if (myModule.getProject().isDisposed())
            return;
        dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myModule.getProject()).getImportingSettings().getDependencyTypesAsSet());
    } finally {
        accessToken.finish();
    }
    for (MavenArtifact artifact : myMavenProject.getDependencies()) {
        String dependencyType = artifact.getType();
        if (!dependencyTypesFromSettings.contains(dependencyType) && !myMavenProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
            continue;
        }
        DependencyScope scope = selectScope(artifact.getScope());
        MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
        if (depProject != null) {
            if (depProject == myMavenProject)
                continue;
            String moduleName = myMavenProjectToModuleName.get(depProject);
            if (moduleName == null || myMavenTree.isIgnored(depProject)) {
                MavenArtifact projectsArtifactInRepository = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
                myRootModelAdapter.addLibraryDependency(projectsArtifactInRepository, scope, myModifiableModelsProvider, myMavenProject);
            } else {
                boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(dependencyType) || "tests".equals(artifact.getClassifier());
                myRootModelAdapter.addModuleDependency(moduleName, scope, isTestJar);
                Element buildHelperCfg = depProject.getPluginGoalConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
                if (buildHelperCfg != null) {
                    addAttachArtifactDependency(buildHelperCfg, scope, depProject, artifact);
                }
                if (IMPORTED_CLASSIFIERS.contains(artifact.getClassifier()) && !isTestJar && !"system".equals(artifact.getScope()) && !"false".equals(System.getProperty("idea.maven.classifier.dep"))) {
                    MavenArtifact a = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
                    myRootModelAdapter.addLibraryDependency(a, scope, myModifiableModelsProvider, myMavenProject);
                }
            }
        } else if ("system".equals(artifact.getScope())) {
            myRootModelAdapter.addSystemDependency(artifact, scope);
        } else {
            myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
        }
    }
    configSurefirePlugin();
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) Element(org.jdom.Element) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) THashSet(gnu.trove.THashSet)

Example 3 with THashSet

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

the class MavenProjectImporter method scheduleRefreshResolvedArtifacts.

private void scheduleRefreshResolvedArtifacts(List<MavenProjectsProcessorTask> postTasks) {
    // We have to refresh all the resolved artifacts manually in order to
    // update all the VirtualFilePointers. It is not enough to call
    // VirtualFileManager.refresh() since the newly created files will be only
    // picked by FS when FileWatcher finishes its work. And in the case of import
    // it doesn't finish in time.
    // I couldn't manage to write a test for this since behaviour of VirtualFileManager
    // and FileWatcher differs from real-life execution.
    List<MavenArtifact> artifacts = new ArrayList<>();
    for (MavenProject each : myProjectsToImportWithChanges.keySet()) {
        artifacts.addAll(each.getDependencies());
    }
    final Set<File> files = new THashSet<>();
    for (MavenArtifact each : artifacts) {
        if (each.isResolved())
            files.add(each.getFile());
    }
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        doRefreshFiles(files);
    } else {
        postTasks.add(new MavenProjectsProcessorTask() {

            public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator) throws MavenProcessCanceledException {
                indicator.setText("Refreshing files...");
                doRefreshFiles(files);
            }
        });
    }
}
Also used : MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) THashSet(gnu.trove.THashSet) Project(com.intellij.openapi.project.Project) MavenProgressIndicator(org.jetbrains.idea.maven.utils.MavenProgressIndicator) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 4 with THashSet

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

the class XmlHighlightingTest method doSchemaTestWithManyFilesFromSeparateDir.

private void doSchemaTestWithManyFilesFromSeparateDir(final String[][] urls, @Nullable Processor<List<VirtualFile>> additionalTestingProcessor) throws Exception {
    try {
        List<VirtualFile> files = new ArrayList<>(6);
        files.add(getVirtualFile(BASE_PATH + getTestName(false) + ".xml"));
        final Set<VirtualFile> usedFiles = new THashSet<>();
        final String base = BASE_PATH + getTestName(false) + "Schemas/";
        for (String[] pair : urls) {
            final String url = pair[0];
            final String filename = pair.length > 1 ? pair[1] : url.substring(url.lastIndexOf('/') + 1) + (url.endsWith(".xsd") ? "" : ".xsd");
            final VirtualFile virtualFile = getVirtualFile(base + filename);
            usedFiles.add(virtualFile);
            if (url != null)
                ExternalResourceManagerExImpl.registerResourceTemporarily(url, virtualFile.getPath(), getTestRootDisposable());
            files.add(virtualFile);
        }
        for (VirtualFile file : LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + base.substring(0, base.length() - 1)).getChildren()) {
            if (!usedFiles.contains(file)) {
                files.add(file);
            }
        }
        doTest(VfsUtilCore.toVirtualFileArray(files), true, false);
        if (additionalTestingProcessor != null)
            additionalTestingProcessor.process(files);
    } finally {
        unregisterResources(urls);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet)

Example 5 with THashSet

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

the class SearchScope method iterateContent.

public void iterateContent(@NotNull final Project project, final Processor<VirtualFile> processor) {
    switch(getScopeType()) {
        case PROJECT:
            //noinspection unchecked
            ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
            break;
        case MODULE:
            final Module module = ModuleManager.getInstance(project).findModuleByName(getModuleName());
            assert module != null;
            ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
            break;
        case DIRECTORY:
            final String dirName = getPath();
            assert dirName != null;
            final VirtualFile virtualFile = findFile(dirName);
            if (virtualFile != null) {
                iterateRecursively(virtualFile, processor, isRecursive());
            }
            break;
        case CUSTOM:
            assert myCustomScope != null;
            final ContentIterator iterator;
            if (myCustomScope instanceof GlobalSearchScope) {
                final GlobalSearchScope searchScope = (GlobalSearchScope) myCustomScope;
                iterator = new MyFileIterator(processor, virtualFile13 -> searchScope.contains(virtualFile13));
                if (searchScope.isSearchInLibraries()) {
                    final OrderEnumerator enumerator = OrderEnumerator.orderEntries(project).withoutModuleSourceEntries().withoutDepModules();
                    final Collection<VirtualFile> libraryFiles = new THashSet<>();
                    Collections.addAll(libraryFiles, enumerator.getClassesRoots());
                    Collections.addAll(libraryFiles, enumerator.getSourceRoots());
                    final Processor<VirtualFile> adapter = virtualFile1 -> iterator.processFile(virtualFile1);
                    for (final VirtualFile file : libraryFiles) {
                        iterateRecursively(file, adapter, true);
                    }
                }
            } else {
                final PsiManager manager = PsiManager.getInstance(project);
                iterator = new MyFileIterator(processor, virtualFile12 -> {
                    final PsiFile element = manager.findFile(virtualFile12);
                    return element != null && PsiSearchScopeUtil.isInScope(myCustomScope, element);
                });
            }
            ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OrderEnumerator(com.intellij.openapi.roots.OrderEnumerator) Tag(com.intellij.util.xmlb.annotations.Tag) ModuleManager(com.intellij.openapi.module.ModuleManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) PsiManager(com.intellij.psi.PsiManager) Comparing(com.intellij.openapi.util.Comparing) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Conditions(com.intellij.openapi.util.Conditions) Module(com.intellij.openapi.module.Module) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) ContentIterator(com.intellij.openapi.roots.ContentIterator) Collection(java.util.Collection) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Nullable(org.jetbrains.annotations.Nullable) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) PsiSearchScopeUtil(com.intellij.psi.search.PsiSearchScopeUtil) Processor(com.intellij.util.Processor) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) Attribute(com.intellij.util.xmlb.annotations.Attribute) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Condition(com.intellij.openapi.util.Condition) ContentIterator(com.intellij.openapi.roots.ContentIterator) PsiManager(com.intellij.psi.PsiManager) THashSet(gnu.trove.THashSet) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) OrderEnumerator(com.intellij.openapi.roots.OrderEnumerator) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module)

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