Java 类org.eclipse.xtext.nodemodel.impl.CompositeNodeWithSemanticElement 实例源码

项目:sadlos2    文件:SadlModelProcessor.java   
protected INode getParserObjectNode(EObject po) {
        Object r = po.eResource();
        if (r instanceof XtextResource) {
            INode root = ((XtextResource) r).getParseResult().getRootNode();
            for(INode node : root.getAsTreeIterable()) {   
                if (node instanceof CompositeNodeWithSemanticElement) {
                    EObject semElt = ((CompositeNodeWithSemanticElement)node).getSemanticElement();
                    if (semElt != null && semElt.equals(po)) {
                        // this is the one!
                        return node;
                    }
                }
            }
        }
        org.eclipse.emf.common.util.TreeIterator<EObject> titr = po.eAllContents();
        while (titr.hasNext()) {
            EObject el = titr.next();
//TODO what's supposed to happen here?
            int i = 0;
        }
        return null;
    }
项目:sadlos2    文件:IntermediateFormTranslator.java   
public String getSourceGrammarText(EObject po) {
        Object r = po.eResource();
        if (r instanceof XtextResource) {
            INode root = ((XtextResource) r).getParseResult().getRootNode();
            for(INode node : root.getAsTreeIterable()) {   
                if (node instanceof CompositeNodeWithSemanticElement) {
                    EObject semElt = ((CompositeNodeWithSemanticElement)node).getSemanticElement();
                    if (semElt.equals(po)) {
                        // this is the one!
                        String txt = NodeModelUtils.getTokenText(node);
                        return txt.trim();
                    }
                }
            }
            org.eclipse.emf.common.util.TreeIterator<EObject> titr = po.eAllContents();
            while (titr.hasNext()) {
                EObject el = titr.next();
// TODO what's supposed to happen here?
                int i = 0;
            }
        }
        return null;
    }
项目:xtext-core    文件:LazyLinkerTest.java   
private ICompositeNode newSimpleNodeAdapter(final INode... nodes) {
    NodeModelBuilder builder = new NodeModelBuilder();
    ICompositeNode result = new CompositeNodeWithSemanticElement();
    for(INode node: nodes) {
        builder.addChild(result, (AbstractNode) node);
    }
    return result;
}
项目:statecharts    文件:SCTLinker.java   
@Override
protected void clearReference(EObject obj, EReference ref) {
    // If the CompositeNodeWithSemanticElement adapter exists, we know that
    // this is an Xtext model element.
    if (EcoreUtil.getAdapter(obj.eAdapters(),
            CompositeNodeWithSemanticElement.class) != null) {
        try {
            obj.eSetDeliver(false);
            super.clearReference(obj, ref);
        } finally {
            obj.eSetDeliver(true);
        }
    }
}
项目:Gauge-Eclipse    文件:SpecHighlightingCalculator.java   
@Override
public void provideHighlightingFor(XtextResource resource,
        IHighlightedPositionAcceptor acceptor) {

    INode root = resource.getParseResult().getRootNode();
       BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();
       while( it.hasNext() )
       {
        INode node = it.next();
        String nodeType="";
        EObject semanticElement = node.getSemanticElement();
        if( node instanceof CompositeNodeWithSemanticElement)
        {
            if(semanticElement instanceof Spec )
                nodeType=SpecHighlightingConfiguration.SPEC;
            else if( semanticElement instanceof Scenario )
                nodeType=SpecHighlightingConfiguration.SCENARIO;
            else if( semanticElement instanceof Tags)
                nodeType=SpecHighlightingConfiguration.TAGS;
            else if( semanticElement instanceof StaticParam )
                nodeType=SpecHighlightingConfiguration.STATIC_PARAM;
            else if( semanticElement instanceof DynamicParam)
                nodeType=SpecHighlightingConfiguration.DYNAMIC_PARAM;
            else if( semanticElement instanceof Step )
                nodeType=SpecHighlightingConfiguration.STEP;
            else
                nodeType=SpecHighlightingConfiguration.DEFAULT;
        }
        acceptor.addPosition(node.getOffset(), node.getLength(), nodeType);
       }
}