Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referencing models defined in files outside of eclipse
Referencing models defined in files outside of eclipse [message #730692] Wed, 28 September 2011 21:41 Go to next message
eecolor is currently offline eecolorFriend
Messages: 36
Registered: September 2011
Member
Hello,

I must be missing something. For days now I have been stepping through the code of xText, reading the forum, setting breakpoints end trying stuff.

I have an external folder that contains dsl files. This external folder will eventually be added to the project in the same style as JDT does (external class folder).

As far as I can see I need to bind an IAllContainersState implementation. The one I have now looks like this:

public class TestStateProjectState extends AbstractAllContainersState implements IAllContainersState {

	@Inject
	private WorkspaceProjectsStateHelper workspaceProjectsStateHelper;
	
	final protected URI getUri(IStorage file) {
		return super.getUri(file);
	}
	
	@Inject
	private ExternalFoldersManager externalFoldersManager;
	
	@Override
	protected String doInitHandle(URI uri) {
		return workspaceProjectsStateHelper.initHandle(uri);
	}

	@Override
	protected Collection<URI> doInitContainedURIs(String containerHandle) {
		if (containerHandle.equals("test"))
		{
			IPath path = new Path("D:/temp");
			
			final Collection<URI> containedURIs = new HashSet<URI>();
			try {
				IFolder folder = externalFoldersManager.createLinkFolder(path, false, new NullProgressMonitor());

				folder.accept(new IResourceVisitor() {
					
					@Override
					public boolean visit(IResource resource) throws CoreException {
						if (resource instanceof IFile)
						{
							URI uri = getUri((IFile) resource);
							containedURIs.add(uri);
							return false;
						}
						return true;
					}
				});
			} catch (CoreException e) {
				e.printStackTrace();
			}
			
			return containedURIs;
		} else
		{
			return workspaceProjectsStateHelper.initContainedURIs(containerHandle);
		}
	}

	@Override
	protected List<String> doInitVisibleHandles(String handle) {
		List<String> initVisibleHandles = workspaceProjectsStateHelper.initVisibleHandles(handle);
		
		if (!initVisibleHandles.contains("test"))
		{
			initVisibleHandles.add("test");
		}
		return initVisibleHandles;
	}
}


The ExternalFoldersManager is modeled after the one from JDT and creates an invisible project to store the locations as linked resources. Their uri looks like this: platform:/resource/.ee.xtext.test.external.folders/.link0/String.test

The State is bound like this (in the ui project):

	public Provider<IAllContainersState> provideIAllContainersState() {
		return org.eclipse.xtext.ui.shared.Access.<IAllContainersState>provider(TestStateProjectState.class);
	}


The mwe2 workflow has these lines:

 fragment = scoping.ImportNamespacesScopingFragment {}
 fragment = exporting.QualifiedNamesFragment {}
 fragment = builder.BuilderIntegrationFragment {}


I do not want to use the JDT features.

As far as I can tell no resource descriptions are being created. What am I missing? How can I tell the index to parse the files in this external folder?
Re: Referencing models defined in files outside of eclipse [message #731586 is a reply to message #730692] Sat, 01 October 2011 21:27 Go to previous message
eecolor is currently offline eecolorFriend
Messages: 36
Registered: September 2011
Member
It seems I was the wrong track. I just need to add a linked resource to the current project. That way it will automatically be picked up by the project builder. Makes a lot more sense.
Previous Topic:Cross Referencing to objects containing white spaces
Next Topic:Cannot run extended 15 minute tutorial
Goto Forum:
  


Current Time: Fri Apr 19 18:59:43 GMT 2024

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

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

Back to the top