Search in sources :

Example 6 with Model

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

the class Bug407280Test method testFindActualSemanticObjectFor.

@Test
public void testFindActualSemanticObjectFor() throws Exception {
    String modelAsString = "actions attribute ref attr1 attr2;";
    int idx = modelAsString.indexOf("attr1");
    Model model = (Model) getModelAndExpect(modelAsString, 1);
    /* linking issue */
    INode root = NodeModelUtils.getNode(model).getRootNode();
    ILeafNode leafNodeAtOffset = NodeModelUtils.findLeafNodeAtOffset(root, idx);
    assertEquals("attr1", leafNodeAtOffset.getText());
    EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(leafNodeAtOffset);
    assertSame(model.getAttributes().get(0), semanticObject);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Model(org.eclipse.xtext.linking.bug287988Test.Model) Test(org.junit.Test)

Aggregations

Model (org.eclipse.xtext.linking.bug287988Test.Model)6 BaseAttribute (org.eclipse.xtext.linking.bug287988Test.BaseAttribute)4 Test (org.junit.Test)4 EObject (org.eclipse.emf.ecore.EObject)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 Attribute (org.eclipse.xtext.linking.bug287988Test.Attribute)1 Master (org.eclipse.xtext.linking.bug287988Test.Master)1