Search in sources :

Example 1 with AliasingPsiTarget

use of com.intellij.psi.targets.AliasingPsiTarget in project intellij-community by JetBrains.

the class RenameAliasingPomTargetProcessor method prepareRenaming.

@Override
public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames) {
    PomTarget target = null;
    if (element instanceof PomTargetPsiElement) {
        target = ((PomTargetPsiElement) element).getTarget();
    } else if (element instanceof PomTarget) {
        target = (PomTarget) element;
    }
    if (target != null) {
        for (AliasingPsiTargetMapper mapper : Extensions.getExtensions(AliasingPsiTargetMapper.EP_NAME)) {
            for (AliasingPsiTarget psiTarget : mapper.getTargets(target)) {
                PsiElement psiElement = PomService.convertToPsi(psiTarget);
                String name = psiTarget.getNameAlias(newName);
                String definedName = allRenames.put(psiElement, name);
                if (definedName != null) {
                    LOG.assertTrue(definedName.equals(name), "target: " + psiTarget + "; " + "defined name: " + definedName + "; " + "name: " + name + "; " + "mapper: " + mapper);
                } else {
                    prepareRenaming(psiElement, name, allRenames);
                }
            }
        }
    }
}
Also used : PomTarget(com.intellij.pom.PomTarget) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) AliasingPsiTarget(com.intellij.psi.targets.AliasingPsiTarget) AliasingPsiTargetMapper(com.intellij.psi.targets.AliasingPsiTargetMapper) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PomTarget (com.intellij.pom.PomTarget)1 PomTargetPsiElement (com.intellij.pom.PomTargetPsiElement)1 PsiElement (com.intellij.psi.PsiElement)1 AliasingPsiTarget (com.intellij.psi.targets.AliasingPsiTarget)1 AliasingPsiTargetMapper (com.intellij.psi.targets.AliasingPsiTargetMapper)1