Search in sources :

Example 21 with HashSet

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

the class ChangeSignatureProcessorBase method filterUsages.

protected static List<UsageInfo> filterUsages(List<UsageInfo> infos) {
    Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<>();
    Set<PsiElement> usedElements = new HashSet<>();
    List<UsageInfo> result = new ArrayList<>(infos.size() / 2);
    for (UsageInfo info : infos) {
        LOG.assertTrue(info != null);
        PsiElement element = info.getElement();
        if (info instanceof MoveRenameUsageInfo) {
            if (usedElements.contains(element))
                continue;
            moveRenameInfos.put(element, (MoveRenameUsageInfo) info);
        } else {
            moveRenameInfos.remove(element);
            usedElements.add(element);
            if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage) info).isCorrect()) {
                result.add(info);
            }
        }
    }
    result.addAll(moveRenameInfos.values());
    return result;
}
Also used : HashMap(com.intellij.util.containers.hash.HashMap) MoveRenameUsageInfo(com.intellij.refactoring.util.MoveRenameUsageInfo) PsiElement(com.intellij.psi.PsiElement) UsageInfo(com.intellij.usageView.UsageInfo) MoveRenameUsageInfo(com.intellij.refactoring.util.MoveRenameUsageInfo) HashSet(com.intellij.util.containers.hash.HashSet)

Example 22 with HashSet

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

the class MavenDomProjectProcessorUtils method searchDependencyUsages.

@NotNull
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model, @NotNull final DependencyConflictId dependencyId, @NotNull final Set<MavenDomDependency> excludes) {
    Project project = model.getManager().getProject();
    final Set<MavenDomDependency> usages = new HashSet<>();
    Processor<MavenDomProjectModel> collectProcessor = mavenDomProjectModel -> {
        for (MavenDomDependency domDependency : mavenDomProjectModel.getDependencies().getDependencies()) {
            if (excludes.contains(domDependency))
                continue;
            if (dependencyId.equals(DependencyConflictId.create(domDependency))) {
                usages.add(domDependency);
            }
        }
        return false;
    };
    processChildrenRecursively(model, collectProcessor, project, new HashSet<>(), true);
    return usages;
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) org.jetbrains.idea.maven.dom.model(org.jetbrains.idea.maven.dom.model) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) org.jetbrains.idea.maven.project(org.jetbrains.idea.maven.project) SmartList(com.intellij.util.SmartList) MavenId(org.jetbrains.idea.maven.model.MavenId) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) HashSet(com.intellij.util.containers.hash.HashSet) DomUtil(com.intellij.util.xml.DomUtil) XmlTag(com.intellij.psi.xml.XmlTag) GenericDomValue(com.intellij.util.xml.GenericDomValue) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) Set(java.util.Set) MavenUtil(org.jetbrains.idea.maven.utils.MavenUtil) Nullable(org.jetbrains.annotations.Nullable) Function(com.intellij.util.Function) Processor(com.intellij.util.Processor) GenericDomValueReference(com.intellij.util.xml.impl.GenericDomValueReference) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) Project(com.intellij.openapi.project.Project) HashSet(com.intellij.util.containers.hash.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with HashSet

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

the class MavenDomProjectProcessorUtils method processParentProjects.

public static void processParentProjects(@NotNull final MavenDomProjectModel projectDom, @NotNull final Processor<MavenDomProjectModel> processor) {
    Set<MavenDomProjectModel> processed = new HashSet<>();
    Project project = projectDom.getManager().getProject();
    MavenDomProjectModel parent = findParent(projectDom, project);
    while (parent != null) {
        if (processed.contains(parent))
            break;
        processed.add(parent);
        if (processor.process(parent))
            break;
        parent = findParent(parent, project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) HashSet(com.intellij.util.containers.hash.HashSet)

Example 24 with HashSet

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

the class MavenDuplicateDependenciesInspection method addProblem.

private static void addProblem(@NotNull MavenDomDependency dependency, @NotNull Collection<MavenDomDependency> dependencies, @NotNull DomElementAnnotationHolder holder) {
    StringBuilder sb = new StringBuilder();
    Set<MavenDomProjectModel> processed = new HashSet<>();
    for (MavenDomDependency domDependency : dependencies) {
        if (dependency.equals(domDependency))
            continue;
        MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
        if (model != null && !processed.contains(model)) {
            if (processed.size() > 0)
                sb.append(", ");
            sb.append(createLinkText(model, domDependency));
            processed.add(model);
        }
    }
    holder.createProblem(dependency, HighlightSeverity.WARNING, MavenDomBundle.message("MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
}
Also used : MavenDomProjectModel(org.jetbrains.idea.maven.dom.model.MavenDomProjectModel) HashSet(com.intellij.util.containers.hash.HashSet) MavenDomDependency(org.jetbrains.idea.maven.dom.model.MavenDomDependency)

Example 25 with HashSet

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

the class MavenDomProjectProcessorUtils method searchManagedPluginUsages.

@NotNull
public static Collection<MavenDomPlugin> searchManagedPluginUsages(@NotNull final MavenDomProjectModel model, @Nullable final String groupId, @NotNull final String artifactId) {
    Project project = model.getManager().getProject();
    final Set<MavenDomPlugin> usages = new HashSet<>();
    Processor<MavenDomProjectModel> collectProcessor = mavenDomProjectModel -> {
        for (MavenDomPlugin domPlugin : mavenDomProjectModel.getBuild().getPlugins().getPlugins()) {
            if (MavenPluginDomUtil.isPlugin(domPlugin, groupId, artifactId)) {
                usages.add(domPlugin);
            }
        }
        return false;
    };
    processChildrenRecursively(model, collectProcessor, project, new HashSet<>(), true);
    return usages;
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) org.jetbrains.idea.maven.dom.model(org.jetbrains.idea.maven.dom.model) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) org.jetbrains.idea.maven.project(org.jetbrains.idea.maven.project) SmartList(com.intellij.util.SmartList) MavenId(org.jetbrains.idea.maven.model.MavenId) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) HashSet(com.intellij.util.containers.hash.HashSet) DomUtil(com.intellij.util.xml.DomUtil) XmlTag(com.intellij.psi.xml.XmlTag) GenericDomValue(com.intellij.util.xml.GenericDomValue) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) Set(java.util.Set) MavenUtil(org.jetbrains.idea.maven.utils.MavenUtil) Nullable(org.jetbrains.annotations.Nullable) Function(com.intellij.util.Function) Processor(com.intellij.util.Processor) GenericDomValueReference(com.intellij.util.xml.impl.GenericDomValueReference) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) Project(com.intellij.openapi.project.Project) HashSet(com.intellij.util.containers.hash.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HashSet (com.intellij.util.containers.hash.HashSet)27 Project (com.intellij.openapi.project.Project)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)5 PsiElement (com.intellij.psi.PsiElement)4 XmlFile (com.intellij.psi.xml.XmlFile)4 Set (java.util.Set)4 Ref (com.intellij.openapi.util.Ref)3 ContainerUtil (com.intellij.util.containers.ContainerUtil)3 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)2 ExcludeEntryDescription (com.intellij.openapi.compiler.options.ExcludeEntryDescription)2 Module (com.intellij.openapi.module.Module)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 PsiClass (com.intellij.psi.PsiClass)2 PsiFile (com.intellij.psi.PsiFile)2 XmlTag (com.intellij.psi.xml.XmlTag)2 Function (com.intellij.util.Function)2 Processor (com.intellij.util.Processor)2 SmartList (com.intellij.util.SmartList)2