Search in sources :

Example 31 with EDataType

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));
}
Also used : EDataType(org.eclipse.emf.ecore.EDataType) Test(org.junit.Test)

Example 32 with EDataType

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;
}
Also used : EDataType(org.eclipse.emf.ecore.EDataType)

Example 33 with EDataType

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;
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) Action(org.eclipse.xtext.Action) EDataType(org.eclipse.emf.ecore.EDataType) EObject(org.eclipse.emf.ecore.EObject) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) CrossReference(org.eclipse.xtext.CrossReference) RuleCall(org.eclipse.xtext.RuleCall)

Example 34 with EDataType

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);
}
Also used : EDataType(org.eclipse.emf.ecore.EDataType) EClassifier(org.eclipse.emf.ecore.EClassifier) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 35 with 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);
}
Also used : EDataType(org.eclipse.emf.ecore.EDataType) EClassifier(org.eclipse.emf.ecore.EClassifier) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Aggregations

EDataType (org.eclipse.emf.ecore.EDataType)48 EClass (org.eclipse.emf.ecore.EClass)21 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)15 EEnum (org.eclipse.emf.ecore.EEnum)14 EClassifier (org.eclipse.emf.ecore.EClassifier)13 EObject (org.eclipse.emf.ecore.EObject)13 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)10 Test (org.junit.Test)10 List (java.util.List)7 ArrayList (java.util.ArrayList)6 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)6 IdEObject (org.bimserver.emf.IdEObject)6 VirtualObject (org.bimserver.shared.VirtualObject)6 EEnumLiteral (org.eclipse.emf.ecore.EEnumLiteral)6 EPackage (org.eclipse.emf.ecore.EPackage)6 HashMapWrappedVirtualObject (org.bimserver.shared.HashMapWrappedVirtualObject)4 EAttribute (org.eclipse.emf.ecore.EAttribute)4 EReference (org.eclipse.emf.ecore.EReference)4 AbstractRule (org.eclipse.xtext.AbstractRule)4 ByteBuffer (java.nio.ByteBuffer)3