/**
  * Calculates the end index of the expected element at allExpectedElements[index]. To determine
  * the end, the subsequent expected elements from the array of all expected elements are used. An
  * element is considered to end one character before the next elements starts.
  */
 protected int getEnd(
     org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal[] allExpectedElements,
     int indexInList) {
   org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal elementAtIndex =
       allExpectedElements[indexInList];
   int startIncludingHidden = elementAtIndex.getStartIncludingHiddenTokens();
   int startExcludingHidden = elementAtIndex.getStartExcludingHiddenTokens();
   for (int i = indexInList + 1; i < allExpectedElements.length; i++) {
     org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal elementAtI =
         allExpectedElements[i];
     int startIncludingHiddenForI = elementAtI.getStartIncludingHiddenTokens();
     int startExcludingHiddenForI = elementAtI.getStartExcludingHiddenTokens();
     if (startIncludingHidden != startIncludingHiddenForI
         || startExcludingHidden != startExcludingHiddenForI) {
       return startIncludingHiddenForI - 1;
     }
   }
   return Integer.MAX_VALUE;
 }
 public org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal[]
     getElementsExpectedAt(
         org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal[]
             allExpectedElements,
         int cursorOffset) {
   List<org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal> expectedAtCursor =
       new ArrayList<org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal>();
   for (int i = 0; i < allExpectedElements.length; i++) {
     org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal expectedElement =
         allExpectedElements[i];
     int startIncludingHidden = expectedElement.getStartIncludingHiddenTokens();
     int end = getEnd(allExpectedElements, i);
     if (cursorOffset >= startIncludingHidden && cursorOffset <= end) {
       expectedAtCursor.add(expectedElement);
     }
   }
   return expectedAtCursor.toArray(
       new org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal
           [expectedAtCursor.size()]);
 }