@Override
 protected IScope getScope(EObject context, EReference reference) {
   IScopeProvider scopeProvider = getScopeProvider();
   if (scopeProvider == null) throw new IllegalStateException("scopeProvider must not be null.");
   //		try {
   //			registerImportedNamesAdapter(context);
   return scopeProvider.getScope(context, reference);
   //		} finally {
   //			unRegisterImportedNamesAdapter();
   //		}
 }
  public String getCrossRefText(
      EObject owner,
      CrossReference crossref,
      EObject target,
      RefTextEvaluator refTextEvaluator,
      ITextRegion linkTextRegion,
      StatusWrapper status) {
    try {
      final EReference ref = GrammarUtil.getReference(crossref, owner.eClass());
      final IScope scope = scopeProvider.getScope(owner, ref);
      if (scope == null) {
        throw new IllegalStateException("Could not create scope for the given cross reference.");
      }
      String ruleName = linkingHelper.getRuleNameFrom(crossref);

      Iterable<IEObjectDescription> descriptionsForCrossRef = scope.getElements(target);
      String bestRefText = null;
      for (IEObjectDescription desc : descriptionsForCrossRef) {
        try {
          String unconvertedRefText = qualifiedNameConverter.toString(desc.getName());
          String convertedRefText = valueConverter.toString(unconvertedRefText, ruleName);
          if (refTextEvaluator.isValid(convertedRefText)
              && (bestRefText == null
                  || refTextEvaluator.isBetterThan(convertedRefText, bestRefText)))
            bestRefText = convertedRefText;
        } catch (ValueConverterException e) {
          status.add(
              RefactoringStatus.WARNING,
              "Missconfigured language: New reference text has invalid syntax.",
              owner,
              linkTextRegion);
        }
      }
      if (bestRefText == null)
        status.add(
            RefactoringStatus.ERROR,
            "Refactoring introduces a name conflict.",
            owner,
            linkTextRegion);
      return bestRefText;

    } catch (Exception exc) {
      status.add(ERROR, exc.getMessage(), owner, linkTextRegion);
      return null;
    }
  }
 /**
  * Overrides the abstract method to find program container and defined types. If not in universal
  * quantified term name context, delegate to super class.
  */
 public IScope getScope(EObject context, EReference reference) {
   System.err.println("reference " + reference);
   /*	if (reference == LPackage.Literals.UNIVERSAL_QUANTIFIED_TERM__NAME) {
   	System.err.println("Finding uqt scope for " + context);
   	Program program = EcoreUtil2.getContainerOfType(context, Program.class);
   	return getTypeIdScope(program);
   }
   if ( reference == LPackage.Literals.EXISTENTIAL_QUANTIFIED_TERM__NAME) {
   	System.err.println("Finding eqt scope for " + context);
   	Program program = EcoreUtil2.getContainerOfType(context, Program.class);
   	return getTypeIdScope(program);
   }
   if (reference == LPackage.Literals.TVAR__ID) {
   	System.err.println("Finding tvar scope for " + context);
   	Program program = EcoreUtil2.getContainerOfType(context, Program.class);
   	return getTypeIdScope(program);
   }
   */
   return delegate.getScope(context, reference);
 }