use of org.eclipse.emf.ecore.EDataType in project xtext-core by eclipse.
the class EcoreUtil2Test method testGetCompatibleType_01.
@Test
public void testGetCompatibleType_01() {
EDataType aString = createEDataType("a", String.class);
EDataType anotherString = createEDataType("b", String.class);
assertSame(aString, EcoreUtil2.getCompatibleType(aString, anotherString, null));
assertSame(anotherString, EcoreUtil2.getCompatibleType(anotherString, aString, null));
}
use of org.eclipse.emf.ecore.EDataType in project xtext-core by eclipse.
the class EcoreUtil2Test method createEDataType.
private EDataType createEDataType(String name, Class<?> instanceClass) {
EDataType result = EcoreFactory.eINSTANCE.createEDataType();
result.setName(name);
result.setInstanceClass(instanceClass);
return result;
}
use of org.eclipse.emf.ecore.EDataType in project xtext-core by eclipse.
the class NodeModelBasedRegionAccessBuilder method isEObjectRoot.
protected boolean isEObjectRoot(INode node) {
if (node instanceof ICompositeNode) {
ICompositeNode parent = node.getParent();
while (parent != null && GrammarUtil.isEObjectFragmentRuleCall(parent.getGrammarElement())) parent = parent.getParent();
if (parent == null)
return true;
INode root = parent;
while (root != null && !root.hasDirectSemanticElement()) root = root.getParent();
if (root == null)
return false;
EObject element = node.getGrammarElement();
if (GrammarUtil.isEObjectRuleCall(element) && !GrammarUtil.isEObjectFragmentRuleCall(element)) {
if (!parent.hasDirectSemanticElement())
return false;
BidiTreeIterator<INode> iterator = node.getAsTreeIterable().iterator();
iterator.next();
while (iterator.hasNext()) {
INode next = iterator.next();
if (next.hasDirectSemanticElement())
return true;
EObject ge = next.getGrammarElement();
if (ge instanceof Action)
return true;
if (ge instanceof RuleCall && GrammarUtil.isAssigned(ge) && ((RuleCall) ge).getRule().getType().getClassifier() instanceof EDataType)
return true;
if (ge instanceof CrossReference)
return true;
}
}
if (element instanceof Action) {
return parent.hasDirectSemanticElement();
}
}
return false;
}
use of org.eclipse.emf.ecore.EDataType in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug413171_01.
@Test
public void testBug413171_01() throws Exception {
Grammar grammar = (Grammar) getModel(readFileIntoString("org/eclipse/xtext/xtext/ecoreInference/Bug413171_01.xtext.txt"));
AbstractRule parserRule = grammar.getRules().get(2);
EClassifier classifier = parserRule.getType().getClassifier();
Assert.assertTrue(parserRule.getName(), classifier instanceof EDataType);
}
use of org.eclipse.emf.ecore.EDataType in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug413171_02.
@Test
public void testBug413171_02() throws Exception {
Grammar grammar = (Grammar) getModel(readFileIntoString("org/eclipse/xtext/xtext/ecoreInference/Bug413171_02.xtext.txt"));
AbstractRule parserRule = grammar.getRules().get(2);
EClassifier classifier = parserRule.getType().getClassifier();
Assert.assertTrue(parserRule.getName(), classifier instanceof EDataType);
}
Aggregations