Search in sources :

Example 6 with Queue

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

the class RenameXmlAttributeProcessor method renameAll.

private static void renameAll(PsiElement originalElement, UsageInfo[] infos, String newName, String originalName) throws IncorrectOperationException {
    if (newName.equals(originalName))
        return;
    Queue<PsiReference> queue = new Queue<>(infos.length);
    for (UsageInfo info : infos) {
        if (info.getElement() == null)
            continue;
        PsiReference ref = info.getReference();
        if (ref == null)
            continue;
        queue.addLast(ref);
    }
    while (!queue.isEmpty()) {
        final PsiReference reference = queue.pullFirst();
        final PsiElement oldElement = reference.getElement();
        if (!oldElement.isValid() || oldElement == originalElement)
            continue;
        final PsiElement newElement = reference.handleElementRename(newName);
        if (!oldElement.isValid()) {
            for (PsiReference psiReference : ReferencesSearch.search(originalElement, new LocalSearchScope(newElement), false)) {
                queue.addLast(psiReference);
            }
        }
    }
}
Also used : LocalSearchScope(com.intellij.psi.search.LocalSearchScope) PsiReference(com.intellij.psi.PsiReference) Queue(com.intellij.util.containers.Queue) UsageInfo(com.intellij.usageView.UsageInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

Queue (com.intellij.util.containers.Queue)6 THashSet (gnu.trove.THashSet)3 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)1 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)1 HintUtil (com.intellij.codeInsight.hint.HintUtil)1 InspectionsBundle (com.intellij.codeInspection.InspectionsBundle)1 com.intellij.codeInspection.ex (com.intellij.codeInspection.ex)1 GlobalInspectionContextImpl (com.intellij.codeInspection.ex.GlobalInspectionContextImpl)1 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)1 RefElement (com.intellij.codeInspection.reference.RefElement)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 ProblemDescriptionNode (com.intellij.codeInspection.ui.ProblemDescriptionNode)1 AllIcons (com.intellij.icons.AllIcons)1 com.intellij.ide (com.intellij.ide)1 SearchUtil (com.intellij.ide.ui.search.SearchUtil)1 SearchableOptionsRegistrar (com.intellij.ide.ui.search.SearchableOptionsRegistrar)1