Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting All DSL Resources in the same Project or dir
Getting All DSL Resources in the same Project or dir [message #1391087] Mon, 30 June 2014 12:29
Thomas Hergenröder is currently offline Thomas HergenröderFriend
Messages: 22
Registered: February 2012
Junior Member
I need all EObjects of one specific Class that are in the same directory or in a subdirectory.

I have a solution that seemded to work,
but it ignores at least one file.
The ignored file is loaded.
It appeard when the same method was called before in the program flow.

edit: The interesting part is that it works fine in the eclipse-Build. But It does not work in the headless build.

Right now I use the following:
public List<IEObjectDescription> getEObjectDescriptions(final Resource resource, final EClass eClass) {
    final List<IEObjectDescription> descriptions = new ArrayList<>();
    final IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(resource);
    final IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(resource.getURI());
    for (final IContainer c : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
        for (final IEObjectDescription ob : c.getExportedObjectsByType(eClass)) {
            if (debug) { System.out.println("added ob: " + ob.getName()); }
            if (ob.getName().toString().contains("MandantenBeziehungenBearbeiten")) {
                System.out.println("ob added MandantenBeziehungenBearbeiten");
    return descriptions;
final Resource resource = module.eResource();
final List<IEObjectDescription> instanceDescriptions = getEObjectDescriptions(resource, eClass);
final ResourceSet resourceSet = resource.getResourceSet();
final String moduleDirPath = resource.getURI();
int i = 0;
for (final IEObjectDescription od : instanceDescriptions) {
    i = i + 1;
    final URI odUri = od.getEObjectURI();
    final String odPath = resource.getURI()(odUri);
    if (odPath.startsWith(moduleDirPath)) {
        final EObject eObject = resourceSet.getEObject(odUri, true);
        if (eObject instanceof StringNamed) {
            stringNameds.add((StringNamed) eObject);

[Updated on: Mon, 30 June 2014 12:55]

Report message to a moderator

Previous Topic: fullyQualifiedName is null when loading Resource from URI
Next Topic:Problems when creating ANSI-C like grammar
Goto Forum:

Current Time: Tue Jun 02 15:20:06 GMT 2020

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

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

Back to the top