use of org.eclipse.xtext.Assignment in project xtext-core by eclipse.
the class SequenceFeeder method accept.
public void accept(Keyword keyword, Object value, int index, ILeafNode node) {
Assignment ass = getAssignment(keyword);
EStructuralFeature feature = getFeature(ass.getFeature());
assertIndex(feature, index);
assertValue(feature, value);
String token = getToken(keyword, value, node);
acceptKeyword(ass, keyword, value, token, index, node);
}
use of org.eclipse.xtext.Assignment in project xtext-core by eclipse.
the class SyntacticSequencerPDAProvider method getType.
protected SynStateType getType(ISerState state) {
switch(state.getType()) {
case ELEMENT:
AbstractElement ele = state.getGrammarElement();
Assignment ass;
if (ele instanceof Action) {
if (((Action) ele).getFeature() == null)
return SynStateType.UNASSIGEND_ACTION_CALL;
else
return SynStateType.ASSIGNED_ACTION_CALL;
} else if (GrammarUtil.containingCrossReference(ele) != null) {
if (ele instanceof RuleCall) {
RuleCall rc = (RuleCall) ele;
if (rc.getRule() instanceof ParserRule)
return SynStateType.ASSIGNED_CROSSREF_DATATYPE_RULE_CALL;
if (rc.getRule() instanceof TerminalRule)
return SynStateType.ASSIGNED_CROSSREF_TERMINAL_RULE_CALL;
if (rc.getRule() instanceof EnumRule)
return SynStateType.ASSIGNED_CROSSREF_ENUM_RULE_CALL;
} else if (ele instanceof Keyword)
return SynStateType.ASSIGNED_CROSSREF_KEYWORD;
} else if ((ass = GrammarUtil.containingAssignment(ele)) != null) {
if (ele instanceof RuleCall) {
RuleCall rc = (RuleCall) ele;
if (rc.getRule() instanceof ParserRule) {
if (rc.getRule().getType().getClassifier() instanceof EClass)
return SynStateType.ASSIGNED_PARSER_RULE_CALL;
return SynStateType.ASSIGNED_DATATYPE_RULE_CALL;
}
if (rc.getRule() instanceof TerminalRule)
return SynStateType.ASSIGNED_TERMINAL_RULE_CALL;
if (rc.getRule() instanceof EnumRule)
return SynStateType.ASSIGNED_ENUM_RULE_CALL;
} else if (ele instanceof Keyword) {
if (GrammarUtil.isBooleanAssignment(ass))
return SynStateType.ASSIGNED_BOOLEAN_KEYWORD;
else
return SynStateType.ASSIGNED_KEYWORD;
}
} else {
if (ele instanceof RuleCall) {
RuleCall rc = (RuleCall) ele;
if (rc.getRule() instanceof ParserRule)
return SynStateType.UNASSIGNED_DATATYPE_RULE_CALL;
if (rc.getRule() instanceof TerminalRule)
return SynStateType.UNASSIGNED_TERMINAL_RULE_CALL;
} else if (ele instanceof Keyword)
return SynStateType.UNASSIGEND_KEYWORD;
}
break;
case PUSH:
return SynStateType.UNASSIGNED_PARSER_RULE_ENTER;
case POP:
return SynStateType.UNASSIGNED_PARSER_RULE_EXIT;
case START:
return SynStateType.START;
case STOP:
return SynStateType.STOP;
}
throw new RuntimeException("no type found for " + state);
}
use of org.eclipse.xtext.Assignment in project xtext-core by eclipse.
the class NodeModelSemanticSequencer method acceptSemantic.
protected boolean acceptSemantic(EObject semanticObject, AbstractElement ele, Object value, INode node) {
Assignment ass = GrammarUtil.containingAssignment(ele);
int index = -2;
if (ass != null) {
EStructuralFeature feat = semanticObject.eClass().getEStructuralFeature(ass.getFeature());
if (feat != null) {
if (feat.isMany())
index = ((List<?>) semanticObject.eGet(feat)).indexOf(value);
else
index = -1;
}
}
String token = node.getText().trim();
if (ele instanceof Action) {
if (((Action) ele).getFeature() != null) {
if (sequenceAcceptor.enterAssignedAction((Action) ele, (EObject) value, (ICompositeNode) node)) {
createSequence(ele, (EObject) value);
sequenceAcceptor.leaveAssignedAction((Action) ele, (EObject) value);
}
return true;
}
} else if (GrammarUtil.containingCrossReference(ele) != null) {
if (ele instanceof RuleCall) {
RuleCall rc = (RuleCall) ele;
if (rc.getRule() instanceof ParserRule) {
sequenceAcceptor.acceptAssignedCrossRefDatatype(rc, token, (EObject) value, index, (ICompositeNode) node);
return true;
}
if (rc.getRule() instanceof TerminalRule) {
sequenceAcceptor.acceptAssignedCrossRefTerminal(rc, token, (EObject) value, index, (ILeafNode) node);
return true;
}
if (rc.getRule() instanceof EnumRule) {
sequenceAcceptor.acceptAssignedCrossRefEnum(rc, token, (EObject) value, index, (ICompositeNode) node);
return true;
}
// } else if (ele instanceof Keyword) {
// acceptor.acceptAssignedCrossRefKeyword((Keyword) ele, token, (EObject) value, index,(ILeafNode) node);
// return true;
}
} else if (ass != null) {
if (ele instanceof RuleCall) {
RuleCall rc = (RuleCall) ele;
if (rc.getRule() instanceof ParserRule) {
if (rc.getRule().getType().getClassifier() instanceof EClass) {
if (sequenceAcceptor.enterAssignedParserRuleCall(rc, (EObject) value, (ICompositeNode) node)) {
createSequence(rc.getRule(), (EObject) value);
sequenceAcceptor.leaveAssignedParserRuleCall(rc, (EObject) value);
}
} else
sequenceAcceptor.acceptAssignedDatatype(rc, token, value, index, (ICompositeNode) node);
return true;
}
if (rc.getRule() instanceof TerminalRule) {
sequenceAcceptor.acceptAssignedTerminal(rc, token, value, index, (ILeafNode) node);
return true;
}
if (rc.getRule() instanceof EnumRule) {
sequenceAcceptor.acceptAssignedEnum(rc, token, value, index, (ICompositeNode) node);
return true;
}
} else if (ele instanceof Keyword) {
if (GrammarUtil.isBooleanAssignment(ass))
sequenceAcceptor.acceptAssignedKeyword((Keyword) ele, token, true, index, (ILeafNode) node);
else
sequenceAcceptor.acceptAssignedKeyword((Keyword) ele, token, (String) value, index, (ILeafNode) node);
return true;
}
}
return false;
}
use of org.eclipse.xtext.Assignment in project xtext-core by eclipse.
the class LazyLinkerTest method newCrossReferenceAssignmentNode.
private INode newCrossReferenceAssignmentNode(final String feature) {
final LeafNode leafNode = new LeafNode();
final Assignment assignment = XtextFactory.eINSTANCE.createAssignment();
assignment.setFeature(feature);
final CrossReference crossReference = XtextFactory.eINSTANCE.createCrossReference();
assignment.setTerminal(crossReference);
leafNode.basicSetGrammarElement(crossReference);
return leafNode;
}
use of org.eclipse.xtext.Assignment in project xtext-core by eclipse.
the class EntryPointFinder method shouldUseParent.
protected boolean shouldUseParent(ICompositeNode result, int offset, ILeafNode leaf) {
if (leaf.getTotalEndOffset() == offset) {
return true;
}
if (result.getGrammarElement() instanceof RuleCall) {
RuleCall rc = (RuleCall) result.getGrammarElement();
if (!rc.getArguments().isEmpty()) {
return true;
}
Assignment assignment = GrammarUtil.containingAssignment(rc);
if (assignment != null && (GrammarUtil.isMultipleCardinality(assignment) || (assignment.eContainer() instanceof AbstractElement && GrammarUtil.isMultipleCardinality((AbstractElement) assignment.eContainer())))) {
return true;
}
}
return false;
}
Aggregations