@Override
  public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
    final DomElement targetDomElement = toDomElement(element);
    if (targetDomElement != null) {
      final AntDomTarget pointingToTarget = targetDomElement.getParentOfType(AntDomTarget.class, false);
      if (pointingToTarget != null) {
          // the aim here is to receive all variants available at this particular context
          final TargetResolver.Result result = doResolve(null);
          if (result != null) {
            final Map<String, AntDomTarget> variants = result.getVariants();
            String newName = null;
            if (!variants.isEmpty()) {
              List<Couple<String>> prefixNamePairs = null;
              for (Map.Entry<String, AntDomTarget> entry : variants.entrySet()) {
                final AntDomTarget candidateTarget = entry.getValue();
                if (pointingToTarget.equals(candidateTarget)) {
                  final String candidateName = entry.getKey();
                  final String candidateTargetName = candidateTarget.getName().getRawText();
                  if (candidateName.endsWith(candidateTargetName)) {
                    final String prefix = candidateName.substring(0, candidateName.length() - candidateTargetName.length());
                    if (prefixNamePairs == null) {
                      prefixNamePairs = new ArrayList<>(); // lazy init
                    }
                    prefixNamePairs.add(Couple.of(prefix, candidateName));
                  }
                }
              }
              final String currentRefText = getCanonicalText();
              for (Couple<String> pair : prefixNamePairs) {
                final String prefix = pair.getFirst();
                final String effectiveName = pair.getSecond();
                if (currentRefText.startsWith(prefix)) {
                  if (newName == null || effectiveName.length() > newName.length()) {
                    // this candidate's prefix matches current reference text and this name is longer
                    // than the previous candidate, then prefer this name
                    newName = effectiveName;
                  }
                }
              }
            }
            if (newName != null) {
              handleElementRename(newName);
              if (myGroup != null) {
                myGroup.textChanged(this, newName);
              }
            }
          }
      }
    }
    return getElement();
  }
@Override
  public PsiElement bindToElement(@NotNull PsiElement element)