Java Code Examples for org.eclipse.xtext.TerminalRule#isFragment()
The following examples show how to use
org.eclipse.xtext.TerminalRule#isFragment() .
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: KeywordInspector.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public void inspectKeywordHidesTerminalRule(Keyword keyword) { AbstractRule container = GrammarUtil.containingRule(keyword); if (container instanceof TerminalRule) return; Grammar grammar = GrammarUtil.getGrammar(container); List<TerminalRule> rules = cache.get(KeywordInspector.class, grammar.eResource(), ()->GrammarUtil.allTerminalRules(grammar)); for(TerminalRule rule: rules) { if (!rule.isFragment()) { AbstractElement element = rule.getAlternatives(); if (element instanceof Keyword && Strings.isEmpty(element.getCardinality())) { String value = ((Keyword) element).getValue(); if (value.equals(keyword.getValue())) acceptor.acceptError( "The keyword '" + value + "' hides the terminal rule " + rule.getName()+ ".", keyword, XtextPackage.Literals.KEYWORD__VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } } }
Example 2
Source File: AbstractDeclarativeValueConverterService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.4 * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. */ protected void registerEFactoryConverters(Map<String, IValueConverter<Object>> converters) { for (ParserRule parserRule : allParserRules(getGrammar())) { if (isDatatypeRule(parserRule)) { registerIfMissing(parserRule.getName(), parserRule, converters); registerIfMissing(ruleNames.getQualifiedName(parserRule), parserRule, converters); } } for (TerminalRule terminalRule : allTerminalRules(getGrammar())) { if (!terminalRule.isFragment()) { registerIfMissing(terminalRule.getName(), terminalRule, converters); registerIfMissing(ruleNames.getQualifiedName(terminalRule), terminalRule, converters); } } }
Example 3
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected CharSequence _compileRule(final TerminalRule it, final Grammar grammar, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _isBacktrackLexer = options.isBacktrackLexer(); if (_isBacktrackLexer) { { boolean _isSyntheticTerminalRule = this._syntheticTerminalDetector.isSyntheticTerminalRule(it); boolean _not = (!_isSyntheticTerminalRule); if (_not) { { boolean _isFragment = it.isFragment(); if (_isFragment) { _builder.append("fragment "); String _ruleName = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName); _builder.append(" : "); String _lexerBody = TerminalRuleToLexerBody.toLexerBody(it); _builder.append(_lexerBody); _builder.append(";"); _builder.newLineIfNotEmpty(); } else { _builder.append("fragment "); String _ruleName_1 = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName_1); _builder.append(" : FRAGMENT_"); String _ruleName_2 = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName_2); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("fragment FRAGMENT_"); String _ruleName_3 = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName_3); _builder.append(" : "); String _lexerBody_1 = TerminalRuleToLexerBody.toLexerBody(it); _builder.append(_lexerBody_1); _builder.append(";"); _builder.newLineIfNotEmpty(); } } } } } else { { boolean _isSyntheticTerminalRule_1 = this._syntheticTerminalDetector.isSyntheticTerminalRule(it); if (_isSyntheticTerminalRule_1) { _builder.append("fragment "); String _ruleName_4 = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName_4); _builder.append(" : ;"); _builder.newLineIfNotEmpty(); } else { { boolean _isFragment_1 = it.isFragment(); if (_isFragment_1) { _builder.append("fragment "); } } String _ruleName_5 = this._grammarAccessExtensions.ruleName(it); _builder.append(_ruleName_5); _builder.append(" : "); String _lexerBody_2 = TerminalRuleToLexerBody.toLexerBody(it); _builder.append(_lexerBody_2); { boolean _shouldBeSkipped = this.shouldBeSkipped(it, grammar); if (_shouldBeSkipped) { _builder.append(" {skip();}"); } } _builder.append(";"); _builder.newLineIfNotEmpty(); } } } } return _builder; }