Search in sources :

Example 11 with Model

use of org.eclipse.xtext.linking.lazy.bug311337.Model in project xtext-core by eclipse.

the class Bug250313Test method testIDConversion_06.

@Test
public void testIDConversion_06() throws Exception {
    Model model = (Model) getModel("1+ ^str");
    assertEquals("[str]", model.getMultiValue().toString());
    assertEquals("org.eclipse.xtext.common.Terminals.ID", lexerRule);
    assertTrue(node instanceof ILeafNode);
    assertEquals("^str", string);
    assertEquals(1, convertCallCount);
}
Also used : ILeafNode(org.eclipse.xtext.nodemodel.ILeafNode) Model(org.eclipse.xtext.valueconverter.bug250313.Model) Test(org.junit.Test)

Example 12 with Model

use of org.eclipse.xtext.linking.lazy.bug311337.Model in project xtext-core by eclipse.

the class Bug250313Test method testNestedDatatypeConversion_10.

@Test
public void testNestedDatatypeConversion_10() throws Exception {
    Model model = (Model) getModel("4+ zonk +");
    assertEquals("[str]", model.getMultiValue().toString());
    assertEquals("org.eclipse.xtext.valueconverter.Bug250313.NestedDatatype", lexerRule);
    assertTrue(node instanceof ICompositeNode);
    assertEquals(4, Iterables.size(((ICompositeNode) node).getChildren()));
    assertEquals("zonk +", string);
    assertEquals(1, convertCallCount);
}
Also used : Model(org.eclipse.xtext.valueconverter.bug250313.Model) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 13 with Model

use of org.eclipse.xtext.linking.lazy.bug311337.Model in project xtext-core by eclipse.

the class Bug250313Test method testKeywordConversion_01.

@Test
public void testKeywordConversion_01() throws Exception {
    Model model = (Model) getModel("1 mykeyword1");
    assertEquals("mykeyword1", model.getValue());
    // XXX value converter is not called for keywords?
    // if this is a bug, all assertions 'assertEquals(1, convertCallCount)' have to be increased
    assertEquals(lexerRule, 0, convertCallCount);
}
Also used : Model(org.eclipse.xtext.valueconverter.bug250313.Model) Test(org.junit.Test)

Example 14 with Model

use of org.eclipse.xtext.linking.lazy.bug311337.Model in project xtext-core by eclipse.

the class Bug305397Test method testBug.

@Test
public void testBug() throws Exception {
    with(new Bug305397StandaloneSetup());
    Model model = (Model) getModel("   a element \n   element X end\n element Y end \nend");
    Element outer = model.getElements().get(0);
    Element firstInner = outer.getElements().get(0);
    ICompositeNode outerNode = NodeModelUtils.getNode(outer);
    assertEquals(3, outerNode.getOffset());
    ICompositeNode firstInnerNode = NodeModelUtils.getNode(firstInner);
    assertEquals(17, firstInnerNode.getOffset());
}
Also used : Element(org.eclipse.xtext.parsetree.impl.bug305397.Element) Model(org.eclipse.xtext.parsetree.impl.bug305397.Model) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 15 with Model

use of org.eclipse.xtext.linking.lazy.bug311337.Model in project xtext-core by eclipse.

the class Bug299395Test method testSerialization_07.

@Test
public void testSerialization_07() {
    Model model = Bug299395Factory.eINSTANCE.createModel();
    SubModel subModel = Bug299395Factory.eINSTANCE.createSubModel();
    model.setSubModel(subModel);
    subModel.getStrings().add("s1");
    String serialized = getSerializer().serialize(model);
    assertEquals("subModel 1 2 \"s1\"", serialized);
}
Also used : Model(org.eclipse.xtext.parsetree.reconstr.bug299395.Model) SubModel(org.eclipse.xtext.parsetree.reconstr.bug299395.SubModel) SubModel(org.eclipse.xtext.parsetree.reconstr.bug299395.SubModel) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)41 Model (org.eclipse.xtext.valueconverter.bug250313.Model)30 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)16 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)11 Model (org.eclipse.xtext.parsetree.reconstr.bug299395.Model)9 SubModel (org.eclipse.xtext.parsetree.reconstr.bug299395.SubModel)9 EPackage (org.eclipse.emf.ecore.EPackage)6 Action (org.eclipse.xtext.Action)6 Parameter (org.eclipse.xtext.Parameter)6 ParserRule (org.eclipse.xtext.ParserRule)6 Model (org.eclipse.xtext.linking.bug362902.Model)2 Model (org.eclipse.xtext.linking.lazy.bug311337.Model)2 Element (org.eclipse.xtext.parsetree.impl.bug305397.Element)2 Model (org.eclipse.xtext.parsetree.impl.bug305397.Model)2 Model (org.eclipse.xtext.parsetree.reconstr.bug302128.Model)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)1 Greeting (org.eclipse.xtext.linking.bug362902.Greeting)1 XtextLinkingDiagnostic (org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic)1 Child (org.eclipse.xtext.linking.lazy.bug311337.Child)1