use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class EmptyModelTest method assertEmptyModel.
private void assertEmptyModel(String model) throws Exception {
IParseResult parseResult = getResource(new StringInputStream(model)).getParseResult();
assertNull(parseResult.getRootASTElement());
ICompositeNode rootNode = parseResult.getRootNode();
assertNotNull(rootNode);
assertEquals(model, rootNode.getText());
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class SerializeTest method checkSerialize.
private void checkSerialize(String model, int expectedErrors) throws Exception {
ICompositeNode node = getRootNodeAndExpect(model, expectedErrors);
String serialize = node.getText();
assertEquals(model, serialize);
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class FormatterTest method testBug471212.
@Test
public void testBug471212() throws Exception {
String model = "test wrappingdt f\nb kw1";
ICompositeNode node = NodeModelUtils.getNode(getModel(model)).getRootNode();
AccessibleFormatter formatter = get(AccessibleFormatter.class);
formatter.setNodeModelStreamer(get(BrokenStreamer.class));
IFormattedRegion region = formatter.format(node, 0, model.length());
String actual = region.getFormattedText();
assertEquals(model, actual);
assertEqualTokenStreams(model);
assertPreserved(model);
}
use of org.eclipse.xtext.nodemodel.ICompositeNode 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());
}
use of org.eclipse.xtext.nodemodel.ICompositeNode in project xtext-core by eclipse.
the class CommentAssociationTest method createModel2CommentMap.
protected Multimap<EObject, String> createModel2CommentMap(Model model) {
ICompositeNode rootNode = NodeModelUtils.getNode(model).getRootNode();
ICommentAssociater commentAssociater = getInjector().getInstance(ICommentAssociater.class);
Map<ILeafNode, EObject> map = commentAssociater.associateCommentsWithSemanticEObjects(model, Collections.singleton(rootNode));
Multimap<EObject, String> multimap = ArrayListMultimap.create();
for (Map.Entry<ILeafNode, EObject> entry : map.entrySet()) {
multimap.put(entry.getValue(), entry.getKey().getText());
}
return multimap;
}
Aggregations