public org.emftext.term.propositional.expression.resource.expression
              .IExpressionReferenceResolveResult<
          ReferenceType>
      resolve() {
    if (resolving) {
      return null;
    }
    resolving = true;
    if (result == null || !result.wasResolved()) {
      result =
          new org.emftext.term.propositional.expression.resource.expression.mopp
                  .ExpressionReferenceResolveResult<
              ReferenceType>(false);
      // set an initial default error message
      result.setErrorMessage(getStdErrorMessage());

      org.emftext.term.propositional.expression.resource.expression.IExpressionReferenceResolver<
              ContainerType, ReferenceType>
          resolver = getResolver();
      // do the actual resolving
      resolver.resolve(
          getIdentifier(), getContainer(), getReference(), getPositionInReference(), false, result);

      // EMFText allows proxies to resolve to multiple objects. The first one is
      // returned, the others are added here to the reference.
      if (result.wasResolvedMultiple()) {
        handleMultipleResults();
      }
    }
    resolving = false;
    return result;
  }
  private void handleMultipleResults() {
    org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> list = null;
    Object temp = container.eGet(reference);
    if (temp instanceof org.eclipse.emf.common.util.EList<?>) {
      list =
          org.emftext.term.propositional.expression.resource.expression.util.ExpressionCastUtil
              .cast(temp);
    }

    boolean first = true;
    for (org.emftext.term.propositional.expression.resource.expression.IExpressionReferenceMapping<
            ReferenceType>
        mapping : result.getMappings()) {
      if (first) {
        first = false;
      } else if (list != null) {
        addResultToList(mapping, proxy, list);
      } else {
        new org.emftext.term.propositional.expression.resource.expression.util
                .ExpressionRuntimeUtil()
            .logError(
                container.eClass().getName()
                    + "."
                    + reference.getName()
                    + " has multiplicity 1 but was resolved to multiple elements",
                null);
      }
    }
  }