use of org.eclipse.xtext.parser.IParseResult 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.parser.IParseResult in project xtext-core by eclipse.
the class AbstractAntlrParser method parse.
@Override
public IParseResult parse(RuleCall ruleCall, Reader reader, int initialLookAhead) {
try {
NodeModelBuilder builder = nodeModelBuilder.get();
builder.setForcedFirstGrammarElement(ruleCall);
IParseResult parseResult = doParse(ruleCall.getRule().getName(), new ANTLRReaderStream(reader), builder, initialLookAhead);
return parseResult;
} catch (IOException e) {
throw new WrappedException(e);
}
}
use of org.eclipse.xtext.parser.IParseResult in project xtext-core by eclipse.
the class SyntheticLinkingLeafNode method getParent.
/**
* @since 2.10
*/
protected CompositeNode getParent(EObject obj, EReference eRef, String crossRefString, int offset, int length) {
ICompositeNode node = NodeModelUtils.getNode(obj);
if (node != null) {
ICompositeNode rootNode = node.getRootNode();
if (rootNode instanceof CompositeNode)
return (CompositeNode) rootNode;
}
Resource resource = obj.eResource();
if (resource instanceof XtextResource) {
IParseResult parseResult = ((XtextResource) resource).getParseResult();
if (parseResult != null) {
ICompositeNode rootNode = parseResult.getRootNode();
if (rootNode instanceof CompositeNode)
return (CompositeNode) rootNode;
}
}
return null;
}
use of org.eclipse.xtext.parser.IParseResult in project xtext-core by eclipse.
the class XtextResourceTest method testUnload.
@Test
public void testUnload() throws Exception {
resource.reparse(simpleModel);
IParseResult parseResult = resource.getParseResult();
resource.unload();
assertNull(resource.getParseResult());
assertTrue(parseResult.getRootASTElement().eIsProxy());
}
use of org.eclipse.xtext.parser.IParseResult in project xtext-core by eclipse.
the class XtextResourceTest method testInitialState.
@Test
public void testInitialState() throws Exception {
assertNotNull(resource);
assertTrue(resource.isLoaded());
assertFalse("resource.isTrackingModification()", resource.isTrackingModification());
assertFalse(resource.isModified());
assertTrue(resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().isEmpty());
IParseResult parseResult = resource.getParseResult();
assertNotNull("parseResult", parseResult);
assertNotNull(parseResult.getRootNode());
assertEquals(0, Iterables.size(parseResult.getSyntaxErrors()));
assertEquals(0, parseResult.getRootNode().getTotalLength());
assertNull(parseResult.getRootASTElement());
}
Aggregations