use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class GrammarParserTest method testKeyword.
@Test
public void testKeyword() throws Exception {
Keyword keyword = (Keyword) getModel("'keyword'");
assertNotNull(keyword);
assertEquals("keyword", keyword.getValue());
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class XtextValidationTest method testCheckCrossReferenceTerminal_05.
@Test
public void testCheckCrossReferenceTerminal_05() throws Exception {
XtextValidator validator = get(XtextValidator.class);
CrossReference reference = XtextFactory.eINSTANCE.createCrossReference();
Keyword keyword = XtextFactory.eINSTANCE.createKeyword();
reference.setTerminal(keyword);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkCrossReferenceTerminal(reference);
messageAcceptor.validate();
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class EnumLiteralSerializer method serializeAssignedEnumLiteral.
@Override
public String serializeAssignedEnumLiteral(EObject context, RuleCall ruleCall, Object value, INode node) {
Keyword nodeLit = getLiteral(node);
Keyword modelLit = getLiteral(context, ruleCall, value);
if (nodeLit != null && nodeLit.equals(modelLit))
return ITokenSerializer.KEEP_VALUE_FROM_NODE_MODEL;
return modelLit.getValue();
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class DefaultLocationInFileProvider method getLocationNodes.
protected List<INode> getLocationNodes(EObject obj) {
final EStructuralFeature nameFeature = getIdentifierFeature(obj);
if (nameFeature != null) {
List<INode> result = NodeModelUtils.findNodesForFeature(obj, nameFeature);
if (!result.isEmpty())
return result;
}
List<INode> resultNodes = Lists.newArrayList();
final ICompositeNode startNode = findNodeFor(obj);
INode keywordNode = null;
// use LeafNodes instead of children?
for (INode child : startNode.getChildren()) {
EObject grammarElement = child.getGrammarElement();
if (grammarElement instanceof RuleCall) {
RuleCall ruleCall = (RuleCall) grammarElement;
String ruleName = ruleCall.getRule().getName();
if (ruleName.equals("ID")) {
resultNodes.add(child);
}
} else if (grammarElement instanceof Keyword) {
// TODO use only keywords, that aren't symbols like '=' ?
if (keywordNode == null && useKeyword((Keyword) grammarElement, obj)) {
keywordNode = child;
}
}
}
if (resultNodes.isEmpty() && keywordNode != null)
resultNodes.add(keywordNode);
return resultNodes;
}
use of org.eclipse.xtext.Keyword in project xtext-core by eclipse.
the class GrammarAccessExtensions method getSingleElementDescription.
private List<String> getSingleElementDescription(final AbstractElement ele) {
final ArrayList<String> r = new ArrayList<String>(2);
boolean _matched = false;
if (ele instanceof Keyword) {
_matched = true;
String _value = ((Keyword) ele).getValue();
r.add(_value);
}
if (!_matched) {
if (ele instanceof Assignment) {
_matched = true;
String _feature = ((Assignment) ele).getFeature();
r.add(_feature);
}
}
if (!_matched) {
if (ele instanceof RuleCall) {
_matched = true;
String _name = ((RuleCall) ele).getRule().getName();
r.add(_name);
}
}
if (!_matched) {
if (ele instanceof Action) {
_matched = true;
TypeRef _type = ((Action) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((Action) ele).getType().getClassifier().getName();
r.add(_name);
}
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(((Action) ele).getFeature());
boolean _not = (!_isNullOrEmpty);
if (_not) {
String _feature = ((Action) ele).getFeature();
r.add(_feature);
}
}
}
if (!_matched) {
if (ele instanceof CrossReference) {
_matched = true;
TypeRef _type = ((CrossReference) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((CrossReference) ele).getType().getClassifier().getName();
r.add(_name);
}
}
}
if (!_matched) {
if (ele instanceof EnumLiteralDeclaration) {
_matched = true;
String _name = ((EnumLiteralDeclaration) ele).getEnumLiteral().getName();
r.add(_name);
}
}
return r;
}
Aggregations