Java Code Examples for org.eclipse.xtext.AbstractElement#eContainer()

The following examples show how to use org.eclipse.xtext.AbstractElement#eContainer() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private List<String> getElementDescription(final AbstractElement element) {
  final ArrayList<String> result = new ArrayList<String>();
  AbstractElement container = element;
  while ((container != null)) {
    {
      result.addAll(0, this.getSingleElementDescription(container));
      final EObject eContainer = container.eContainer();
      AbstractElement _xifexpression = null;
      if ((eContainer instanceof AbstractElement)) {
        _xifexpression = ((AbstractElement)eContainer);
      } else {
        _xifexpression = null;
      }
      container = _xifexpression;
    }
  }
  return result;
}
 
Example 2
/**
 * @since 2.14
 */
protected String[][] getAdjustedRequiredRuleNames(Param param, AbstractElement elementToParse,
		String originalRuleName) {
	String adjustedRuleName = adjustRuleName(originalRuleName, param);
	if (!(GrammarUtil.isOptionalCardinality(elementToParse)
			|| GrammarUtil.isOneOrMoreCardinality(elementToParse))) {
		return new String[][] { { adjustedRuleName } };
	}
	EObject container = elementToParse.eContainer();
	if (container instanceof Group) {
		Group group = (Group) container;
		List<AbstractElement> filteredElements = getFilteredElements(group.getElements(), param);
		int idx = filteredElements.indexOf(elementToParse) + 1;
		if (idx != filteredElements.size()) {
			String adjustedSecondRule = getAdjustedSecondRule(param, group, idx);
			return getRuleNamesInGroup(param, elementToParse, adjustedRuleName, adjustedSecondRule);
		}
	}
	return new String[][] { { adjustedRuleName } };
}
 
Example 3
private boolean hasMandatoryFollowElements(final AbstractElement lastParsedElement) {
  if (lastParsedElement.eContainer() instanceof AbstractElement) {
    AbstractElement directParent = (AbstractElement) lastParsedElement.eContainer();
    if (directParent instanceof Group) {
      Group group = (Group) directParent;
      int idx = group.getElements().indexOf(lastParsedElement) + 1;
      for (int i = idx; i < group.getElements().size(); i++) {
        if (isMandatory(group.getElements().get(i))) {
          return true;
        }
      }
    }
    return hasMandatoryFollowElements(directParent);
  }
  return false;
}
 
Example 4
private boolean isMultipleCardinality(AbstractElement e) {
	if (GrammarUtil.isMultipleCardinality(e)) {
		return true;
	}
	if (e.eContainer() instanceof AbstractElement) {
		return isMultipleCardinality((AbstractElement) e.eContainer());
	}
	return false;
}
 
Example 5
private static List<String> getElementDescription(AbstractElement element) {
	final ArrayList<String> result = new ArrayList<String>();
	AbstractElement container = element;
	while (container != null) {
		result.addAll(0, getSingleElementDescription(container));
		container = container.eContainer() instanceof AbstractElement ? (AbstractElement) container
				.eContainer()
				: null;
	}
	return result;
}
 
Example 6
private boolean hasMandatoryFollowElements(AbstractElement lastParsedElement) {
	if (lastParsedElement.eContainer() instanceof AbstractElement) {
		AbstractElement directParent = (AbstractElement) lastParsedElement.eContainer();
		if (directParent instanceof Group) {
			Group group = (Group) directParent;
			int idx = group.getElements().indexOf(lastParsedElement) + 1;
			for (int i = idx; i < group.getElements().size(); i++) {
				if (isMandatory(group.getElements().get(i)))
					return true;
			}
		}
		return hasMandatoryFollowElements(directParent);
	}
	return false;
}
 
Example 7
@Override
public boolean filter(AbstractElement grammarElement) {
	if (grammarElement.eContainer() instanceof AbstractRule)
		return false;
	if (EcoreUtil2.getContainerOfType(grammarElement.eContainer(), Assignment.class) != null)
		return true;

	return false;
}
 
Example 8
protected String loadElementParentStatement(final AbstractElement ele) {
  String _xifexpression = null;
  EObject _eContainer = ele.eContainer();
  if ((_eContainer instanceof AbstractElement)) {
    EObject _eContainer_1 = ele.eContainer();
    _xifexpression = this.gaElementAccessorLocalVarName(((AbstractElement) _eContainer_1));
  } else {
    _xifexpression = "rule";
  }
  return _xifexpression;
}
 
Example 9
/**
 * Return the containing group if it contains exactly one element.
 * 
 * @since 2.14
 */
protected AbstractElement getEnclosingSingleElementGroup(AbstractElement elementToParse) {
	EObject container = elementToParse.eContainer();
	if (container instanceof Group) {
		if (((Group) container).getElements().size() == 1) {
			return (AbstractElement) container;
		}
	}
	return null;
}
 
Example 10
Source Project: xtext-core   File: CfgAdapter.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public AbstractElement getParent(AbstractElement ele) {
	EObject cnt = ele.eContainer();
	return cnt instanceof AbstractElement ? (AbstractElement) cnt : null;
}