use of org.eclipse.xtext.ide.editor.contentassist.antlr.LookaheadKeyword in project xtext-core by eclipse.
the class AbstractInternalContentAssistParser method createLookAheadTerminal.
@Override
public LookAheadTerminal createLookAheadTerminal(Token token) {
Grammar grammar = getGrammar();
String tokenName = getTokenNames()[token.getType()];
tokenName = getValueForTokenName(tokenName);
if (tokenName.charAt(0) == '\'') {
LookaheadKeyword result = new LookaheadKeyword();
result.setKeyword(tokenName.substring(1, tokenName.length() - 1));
result.setToken(token);
return result;
}
LookAheadTerminalRuleCall result = new LookAheadTerminalRuleCall();
result.setToken(token);
String ruleName = TokenTool.getLexerRuleName(tokenName);
if (terminalRules == null)
terminalRules = GrammarUtil.allTerminalRules(grammar);
for (TerminalRule rule : terminalRules) {
if (rule.getName().equalsIgnoreCase(ruleName)) {
result.setRule(rule);
return result;
}
}
throw new IllegalArgumentException("tokenType " + token.getType() + " seems to be invalid.");
}
use of org.eclipse.xtext.ide.editor.contentassist.antlr.LookaheadKeyword in project xtext-xtend by eclipse.
the class FlexerBasedInternalContentAssistParser method createLookAheadTerminal.
@Override
public LookAheadTerminal createLookAheadTerminal(Token token) {
Grammar grammar = getGrammar();
String tokenName = getTokenDefMap().get(token.getType());
if (tokenName.charAt(0) == '\'') {
LookaheadKeyword result = new LookaheadKeyword();
result.setKeyword(tokenName.substring(1, tokenName.length() - 1));
result.setToken(token);
return result;
}
LookAheadTerminalRuleCall result = new LookAheadTerminalRuleCall();
result.setToken(token);
String ruleName = tokenName.substring(5);
if (terminalRules == null)
terminalRules = GrammarUtil.allTerminalRules(grammar);
for (TerminalRule rule : terminalRules) {
if (rule.getName().equalsIgnoreCase(ruleName)) {
result.setRule(rule);
return result;
}
}
throw new IllegalArgumentException("tokenType " + token.getType() + " seems to be invalid.");
}
Aggregations