use of org.eclipse.xtext.Keyword in project xtext-xtend by eclipse.
the class XtendSyntacticSequencer method emit_XBlockExpression_SemicolonKeyword_2_1_q.
/**
* Syntax:
* ';'?
*/
@Override
protected void emit_XBlockExpression_SemicolonKeyword_2_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
if (semicolonBeforeNextExpressionRequired) {
ILeafNode node = nodes != null && nodes.size() == 1 && nodes.get(0) instanceof ILeafNode ? (ILeafNode) nodes.get(0) : null;
Keyword kw = grammarAccess.getXBlockExpressionAccess().getSemicolonKeyword_2_1();
acceptUnassignedKeyword(kw, kw.getValue(), node);
} else
acceptNodes(transition, nodes);
}
use of org.eclipse.xtext.Keyword in project xtext-xtend by eclipse.
the class XtendSyntacticSequencer method emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a.
/**
* Syntax: '('*
*/
@Override
protected void emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
Keyword kw = grammarAccess.getXParenthesizedExpressionAccess().getLeftParenthesisKeyword_0();
if (nodes == null) {
if (semanticObject instanceof XIfExpression || semanticObject instanceof XTryCatchFinallyExpression) {
EObject cnt = semanticObject.eContainer();
if (cnt instanceof XExpression && !(cnt instanceof XBlockExpression) && !(cnt instanceof XForLoopExpression))
acceptUnassignedKeyword(kw, kw.getValue(), null);
}
if (semanticObject instanceof XConstructorCall) {
XConstructorCall call = (XConstructorCall) semanticObject;
if (!call.isExplicitConstructorCall() && call.getArguments().isEmpty()) {
acceptUnassignedKeyword(kw, kw.getValue(), null);
}
}
}
acceptNodes(transition, nodes);
}
use of org.eclipse.xtext.Keyword in project xtext-xtend by eclipse.
the class CreateMemberQuickfixes method getFirstOffsetOfKeyword.
/**
* @since 2.3
*/
protected int getFirstOffsetOfKeyword(EObject object, String keyword) {
int offset = -1;
ICompositeNode node = NodeModelUtils.getNode(object);
if (node != null) {
for (ILeafNode leafNode : node.getLeafNodes()) {
if (leafNode.getGrammarElement() instanceof Keyword && equal(keyword, ((Keyword) leafNode.getGrammarElement()).getValue())) {
return leafNode.getOffset() + 1;
}
}
}
return offset;
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class ContentAssistContextFactory method isLikelyToBeValidProposal.
protected boolean isLikelyToBeValidProposal(INode lastCompleteNode, Iterable<ContentAssistContext> contexts) {
for (ContentAssistContext context : contexts) {
for (AbstractElement element : context.getFirstSetGrammarElements()) {
if (element instanceof Keyword) {
String keywordValue = ((Keyword) element).getValue();
String lastText = ((ILeafNode) lastCompleteNode).getText();
if (keywordValue.equals(lastText))
return true;
}
}
}
return false;
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class AbstractSyntacticSequencer method accept.
@SuppressWarnings("deprecation")
protected void accept(ISynState emitter, INode node, RuleCallStack stack) {
switch(emitter.getType()) {
case UNASSIGNED_PARSER_RULE_ENTER:
RuleCall rc1 = (RuleCall) emitter.getGrammarElement();
delegate.enterUnassignedParserRuleCall(rc1);
stack.push(rc1);
return;
case UNASSIGNED_PARSER_RULE_EXIT:
RuleCall rc2 = (RuleCall) emitter.getGrammarElement();
delegate.leaveUnssignedParserRuleCall(rc2);
RuleCall lastRc = stack.pop();
if (lastRc != rc2) {
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createUnexpectedStackStateDiagnostic(contexts.get(contexts.size() - 1).semanticObject, stack, lastRc, emitter));
}
return;
case UNASSIGEND_ACTION_CALL:
delegate.acceptUnassignedAction((Action) emitter.getGrammarElement());
return;
case UNASSIGEND_KEYWORD:
Keyword keyword = (Keyword) emitter.getGrammarElement();
String token = node != null ? node.getText() : keyword.getValue();
delegate.acceptUnassignedKeyword(keyword, token, (ILeafNode) node);
return;
case UNASSIGNED_DATATYPE_RULE_CALL:
RuleCall rc3 = (RuleCall) emitter.getGrammarElement();
String value3 = getUnassignedRuleCallToken(rc3, node);
delegate.acceptUnassignedDatatype(rc3, value3, (ICompositeNode) node);
return;
case UNASSIGNED_TERMINAL_RULE_CALL:
RuleCall rc4 = (RuleCall) emitter.getGrammarElement();
String value4 = getUnassignedRuleCallToken(rc4, node);
delegate.acceptUnassignedTerminal(rc4, value4, (ILeafNode) node);
return;
case ASSIGNED_ACTION_CALL:
case ASSIGNED_BOOLEAN_KEYWORD:
case ASSIGNED_CROSSREF_DATATYPE_RULE_CALL:
case ASSIGNED_CROSSREF_ENUM_RULE_CALL:
case ASSIGNED_CROSSREF_KEYWORD:
case ASSIGNED_CROSSREF_TERMINAL_RULE_CALL:
case ASSIGNED_DATATYPE_RULE_CALL:
case ASSIGNED_ENUM_RULE_CALL:
case ASSIGNED_KEYWORD:
case ASSIGNED_PARSER_RULE_CALL:
case ASSIGNED_TERMINAL_RULE_CALL:
case START:
case STOP:
case TRANSITION:
}
throw new RuntimeException("invalid state for emitting: " + emitter + " (" + emitter.getType() + ")");
}
Aggregations