Search in sources :

Example 1 with IDefaultResourceDescriptionStrategy

use of org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy in project n4js by eclipse.

the class GlobalObjectScope method buildMap.

@Override
protected void buildMap(Resource resource, Map<QualifiedName, IEObjectDescription> elements) {
    IDefaultResourceDescriptionStrategy strategy = ((XtextResource) resource).getResourceServiceProvider().get(IDefaultResourceDescriptionStrategy.class);
    TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(resource, false);
    IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {

        @Override
        public void accept(IEObjectDescription description) {
            elements.put(description.getQualifiedName(), description);
        }
    };
    while (allProperContents.hasNext()) {
        EObject content = allProperContents.next();
        if (!strategy.createEObjectDescriptions(content, acceptor)) {
            allProperContents.prune();
        }
    }
}
Also used : IDefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy) EObject(org.eclipse.emf.ecore.EObject) IAcceptor(org.eclipse.xtext.util.IAcceptor) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 IDefaultResourceDescriptionStrategy (org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IAcceptor (org.eclipse.xtext.util.IAcceptor)1