Java Code Examples for org.eclipse.xtext.Grammar#isDefinesHiddenTokens()

The following examples show how to use org.eclipse.xtext.Grammar#isDefinesHiddenTokens() . 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
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public List<String> initialHiddenTokens(final Grammar it) {
  List<String> _xblockexpression = null;
  {
    boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
    if (_isDefinesHiddenTokens) {
      final Function1<AbstractRule, String> _function = (AbstractRule it_1) -> {
        return this.ruleName(it_1);
      };
      return IterableExtensions.<String>toList(ListExtensions.<AbstractRule, String>map(it.getHiddenTokens(), _function));
    }
    int _size = it.getUsedGrammars().size();
    boolean _equals = (_size == 1);
    if (_equals) {
      return this.initialHiddenTokens(IterableExtensions.<Grammar>head(it.getUsedGrammars()));
    }
    _xblockexpression = CollectionLiterals.<String>emptyList();
  }
  return _xblockexpression;
}
 
Example 2
Source File: UsedRulesFinder.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Void caseGrammar(Grammar object) {
	if (!visitedGrammars.add(object))
		return null;
	if (object.isDefinesHiddenTokens())
		for(AbstractRule rule: object.getHiddenTokens())
			doSwitch(rule);
	for(Grammar grammar: object.getUsedGrammars()) {
		caseGrammar(grammar);
	}
	return null;
}
 
Example 3
Source File: FlattenedGrammarAccess.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void setHiddenTokens(Grammar copy, Grammar orig, Map<RuleWithParameterValues, AbstractRule> origToCopy) {
	if (orig == null) {
		copy.setDefinesHiddenTokens(true);
		return;
	}
	if (!orig.isDefinesHiddenTokens()) {
		setHiddenTokens(copy, head(orig.getUsedGrammars()), origToCopy);
		return;
	}
	copy.setDefinesHiddenTokens(true);
	addAll(copy.getHiddenTokens(), ListExtensions.map(orig.getHiddenTokens(),
			hidden -> origToCopy.get(new RuleWithParameterValues(hidden))));
}
 
Example 4
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Check
public void checkHiddenTokenIsNotAFragment(Grammar grammar) {
	if (grammar.isDefinesHiddenTokens()) {
		checkHiddenTokenIsNotAFragment(grammar, grammar.getHiddenTokens(), XtextPackage.Literals.GRAMMAR__HIDDEN_TOKENS);
	}
}