Search in sources :

Example 6 with IAcceptor

use of org.eclipse.xtext.util.IAcceptor in project xtext-core by eclipse.

the class DefaultResourceDescription method computeExportedObjects.

@Override
protected List<IEObjectDescription> computeExportedObjects() {
    if (!getResource().isLoaded()) {
        try {
            getResource().load(null);
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            return Collections.<IEObjectDescription>emptyList();
        }
    }
    final List<IEObjectDescription> exportedEObjects = newArrayList();
    IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {

        @Override
        public void accept(IEObjectDescription eObjectDescription) {
            exportedEObjects.add(eObjectDescription);
        }
    };
    TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(getResource(), false);
    while (allProperContents.hasNext()) {
        EObject content = allProperContents.next();
        if (!strategy.createEObjectDescriptions(content, acceptor))
            allProperContents.prune();
    }
    return exportedEObjects;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IAcceptor(org.eclipse.xtext.util.IAcceptor) IOException(java.io.IOException) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

IAcceptor (org.eclipse.xtext.util.IAcceptor)6 EObject (org.eclipse.emf.ecore.EObject)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 FormatterRequest (org.eclipse.xtext.formatting2.FormatterRequest)2 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)2 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)2 ConflictingRegionsException (org.eclipse.xtext.formatting2.internal.ConflictingRegionsException)2 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)2 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)2 IDList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.IDList)2 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 Wrapper (org.eclipse.xtext.util.Wrapper)2 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 IProject (org.eclipse.core.resources.IProject)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 DispatchHelper (org.eclipse.xtend.core.jvmmodel.DispatchHelper)1