[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.tmf] Re: ISemanticModelTransformer and virtual nodes.

Drew,

drew frantz wrote on Thu, 17 September 2009 17:17
I am still get an exception thrown in my VirtualNode. Note my VirtualNode is not an Eobjetc, which I think is part of the problem. I am essential trying to wrap some EObject sin virtual nodes so that I display other things beneath the Virtual nodes that are not EObjects.

java.lang.ClassCastException: com.aleri.ccl.xtext.outline.VirtualNode
at org.eclipse.xtext.ui.common.editor.outline.transformer.Abstr actSemanticModelTransformer.transformSemanticChildNodes(Abst ractSemanticModelTransformer.java:61)


Here is the code..


/////////////// public class VirtualNode { public TopStatements myTop;

   public VirtualNode(TopStatements model)
   {
    myTop = model;
   }
   public String getName()
   {
    return "Folder";
   }
}

/////////////
protected List<EObject> getChildren(VirtualNode semanticNode)
{
   List<EObject> result = new ArrayList<EObject>();
   Iterator <TopStatement> it =semanticNode.myTop.getStmts().iterator();
   while(it.hasNext())
   {
    TopStatement st = it.next();
    if(st instanceof CreateModuleStatement)
    {
     result.add(st);
    }
   }
  //result.addAll( semanticNode.myTop.getStmts());
  return result;

 }
 protected List<VirtualNode> getChildren(TopStatements model) {
    List<VirtualNode> result = new ArrayList<VirtualNode>();
    VirtualNode apples = new VirtualNode(model);

    result.add(apples);
    return result;
  }


Exactly, the VirtualNodes need to be EObjects. And since we will try to access their resource in  org.eclipse.xtext.ui.common.editor.outline.transformer.Defau ltSemanticModelTransformer.newOutlineNode(EObject, ContentOutlineNode), they need to be added to a resource, which is why I just wrapped the parent element. Certainly not the most intuitive way to do things, I agree. We might consider reshaping the outline / transformer API slightly to better match your needs. Feel free to open a bug / feature request so we can work on this.