Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What is this error about?
What is this error about? [message #660894] Tue, 22 March 2011 09:26 Go to next message
Preeyavis Pringsulaka is currently offline Preeyavis PringsulakaFriend
Messages: 8
Registered: February 2011
Junior Member
Hi,
I am trying to get my resource. The error is;

Exception in thread "main" org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception: index=0, size=0

My code is about;


public class GetResource {
public static void main(String[] args) {
new DslmigrationStandaloneSetup().createInjectorAndDoEMFRegistra tion();
ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.getResource(URI.createURI("./src/pree.mydsl"), true);
Model model = (Model) resource.getContents().get(0);
CompositeNode node = NodeUtil.getRootNode(model);
Iterable<AbstractNode> contents = NodeUtil.getAllContents(node);
StringBuffer text = new StringBuffer();
for (AbstractNode abstractNode : contents) {
if (abstractNode instanceof LeafNode)
text.append(((LeafNode)abstractNode).getText());
}
System.out.println(text);
}
}
Thanks
Re: What is this error about? [message #660905 is a reply to message #660894] Tue, 22 March 2011 09:55 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

it would help if you'd tell which of your lines causes the error but it seems like you somewhere access an element in a list of size zero which results in the EMF kind of ArrayOutOfBoundsException.

e.g. Model model = (Model) resource.getContents().get(0);
is you don't have anything in the model.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Error when loading the resource
Next Topic:[Xtext] ScopeProvider - How to scope differently two calls to the same parser rule ?
Goto Forum:
  


Current Time: Thu Mar 28 20:30:50 GMT 2024

Powered by FUDForum. Page generated in 0.02154 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top