Search in sources :

Example 1 with SmartHashSet

use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.

the class DependencyResolvingBuilder method getRepositoryLibraries.

@NotNull
private static Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> getRepositoryLibraries(ModuleChunk chunk) {
    final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> result = new SmartHashSet<>();
    for (JpsModule module : chunk.getModules()) {
        for (JpsDependencyElement dep : module.getDependenciesList().getDependencies()) {
            if (dep instanceof JpsLibraryDependency) {
                final JpsLibrary _lib = ((JpsLibraryDependency) dep).getLibrary();
                final JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib = _lib != null ? _lib.asTyped(JpsMavenRepositoryLibraryType.INSTANCE) : null;
                if (lib != null) {
                    result.add(lib);
                }
            }
        }
    }
    return result;
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) SmartHashSet(com.intellij.util.containers.SmartHashSet) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsTypedLibrary(org.jetbrains.jps.model.library.JpsTypedLibrary) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) RepositoryLibraryDescriptor(org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SmartHashSet

use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.

the class LogFileOptions method getPaths.

@NotNull
public Set<String> getPaths() {
    File logFile = new File(myPathPattern);
    if (logFile.exists()) {
        return Collections.singleton(myPathPattern);
    }
    int dirIndex = myPathPattern.lastIndexOf(File.separator);
    if (dirIndex == -1) {
        return Collections.emptySet();
    }
    List<File> files = new SmartList<>();
    collectMatchedFiles(new File(myPathPattern.substring(0, dirIndex)), Pattern.compile(FileUtil.convertAntToRegexp(myPathPattern.substring(dirIndex + File.separator.length()))), files);
    if (files.isEmpty()) {
        return Collections.emptySet();
    }
    if (myShowAll) {
        SmartHashSet<String> result = new SmartHashSet<>();
        result.ensureCapacity(files.size());
        for (File file : files) {
            result.add(file.getPath());
        }
        return result;
    } else {
        File lastFile = null;
        for (File file : files) {
            if (lastFile != null) {
                if (file.lastModified() > lastFile.lastModified()) {
                    lastFile = file;
                }
            } else {
                lastFile = file;
            }
        }
        assert lastFile != null;
        return Collections.singleton(lastFile.getPath());
    }
}
Also used : SmartHashSet(com.intellij.util.containers.SmartHashSet) SmartList(com.intellij.util.SmartList) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with SmartHashSet

use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.

the class InspectionEngine method getDialectIdsSpecifiedForTool.

@Nullable("null means not specified")
public static Set<String> getDialectIdsSpecifiedForTool(@NotNull LocalInspectionToolWrapper wrapper) {
    String langId = wrapper.getLanguage();
    if (langId == null) {
        return null;
    }
    Language language = Language.findLanguageByID(langId);
    Set<String> result;
    if (language == null) {
        // unknown language in plugin.xml, ignore
        result = Collections.singleton(langId);
    } else {
        List<Language> dialects = language.getDialects();
        boolean applyToDialects = wrapper.applyToDialects();
        result = applyToDialects && !dialects.isEmpty() ? new THashSet<>(1 + dialects.size()) : new SmartHashSet<>();
        result.add(langId);
        if (applyToDialects) {
            for (Language dialect : dialects) {
                result.add(dialect.getID());
            }
        }
    }
    return result;
}
Also used : SmartHashSet(com.intellij.util.containers.SmartHashSet) Language(com.intellij.lang.Language) THashSet(gnu.trove.THashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with SmartHashSet

use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.

the class LocalInspectionsPass method getElementsAndDialectsFrom.

private static void getElementsAndDialectsFrom(@NotNull PsiFile file, @NotNull List<PsiElement> outElements, @NotNull Set<String> outDialects) {
    final FileViewProvider viewProvider = file.getViewProvider();
    final Set<PsiElement> result = new LinkedHashSet<>();
    Set<Language> processedLanguages = new SmartHashSet<>();
    final PsiElementVisitor visitor = new PsiRecursiveElementVisitor() {

        @Override
        public void visitElement(PsiElement element) {
            ProgressManager.checkCanceled();
            PsiElement child = element.getFirstChild();
            if (child == null) {
            // leaf element
            } else {
                // composite element
                while (child != null) {
                    child.accept(this);
                    result.add(child);
                    appendDialects(child, processedLanguages, outDialects);
                    child = child.getNextSibling();
                }
            }
        }
    };
    for (Language language : viewProvider.getLanguages()) {
        final PsiFile psiRoot = viewProvider.getPsi(language);
        if (psiRoot == null || !HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(psiRoot)) {
            continue;
        }
        psiRoot.accept(visitor);
        result.add(psiRoot);
        appendDialects(psiRoot, processedLanguages, outDialects);
    }
    outElements.addAll(result);
}
Also used : SmartHashSet(com.intellij.util.containers.SmartHashSet) Language(com.intellij.lang.Language)

Example 5 with SmartHashSet

use of com.intellij.util.containers.SmartHashSet in project oxy-template-support-plugin by mutant-industries.

the class ExtenderProvider method getExtenders.

@NotNull
public static Set<PsiClass> getExtenders(@NotNull PsiClass original) {
    Set<PsiClass> result = new SmartHashSet<>();
    PsiClass extender;
    for (PsiClass psiClass : getExtenderProvidersFor(original)) {
        if ((extender = getExtenderFromProvider(psiClass)) != null) {
            result.add(extender);
        }
    }
    return result;
}
Also used : SmartHashSet(com.intellij.util.containers.SmartHashSet) PsiClass(com.intellij.psi.PsiClass) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SmartHashSet (com.intellij.util.containers.SmartHashSet)5 NotNull (org.jetbrains.annotations.NotNull)3 Language (com.intellij.lang.Language)2 PsiClass (com.intellij.psi.PsiClass)1 SmartList (com.intellij.util.SmartList)1 THashSet (gnu.trove.THashSet)1 File (java.io.File)1 Nullable (org.jetbrains.annotations.Nullable)1 RepositoryLibraryDescriptor (org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor)1 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)1 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)1 JpsTypedLibrary (org.jetbrains.jps.model.library.JpsTypedLibrary)1 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)1 JpsLibraryDependency (org.jetbrains.jps.model.module.JpsLibraryDependency)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1