Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to set working directory for import URIs
How to set working directory for import URIs [message #1061512] Sat, 01 June 2013 08:47 Go to next message
Marco Naddeo is currently offline Marco Naddeo
Messages: 62
Registered: November 2012
Member
Hi all. Smile

I want to set the working directory for import URIs in my DSL to be the root of the project in which the resource which declares the import is contained. For example, if I have this directory structure:

MyProject
->MyFolderA
  ->MyFolderB
    ->MySourceFile1.mydsl
  ->MyFolderC
    ->MySourceFile2.mydsl



If I have to import MySourceFile1.mydsl into MySourceFile2.mydsl, I don't want to specify this import as default:

import "../MyFolderB/MySourceFile1.mydsl"


but I want to specify it in this way:

import "MyFolderA/MyFolderB/MySourceFile1.mydsl"


How can I obtain this?


Thanks in advance,
Marco
Re: How to set working directory for import URIs [message #1062057 is a reply to message #1061512] Wed, 05 June 2013 11:14 Go to previous message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
Hi Marco,

I did something similar. I created a subclass of ImportUriGlobalScopeProvider and overrode getImportedUris. Instead of just checking if each import was a valid URI relative to the resource at hand, I checked it appended to the project path:

    String projectName = resource.getURI().segment(1);
    Project project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    IPath projectPath = project.getLocation();
    IPath importPath = projectPath.append(importString);
Previous Topic:p2 update site broken ?
Next Topic:Organise imports in my DSL
Goto Forum:
  


Current Time: Mon Apr 21 08:50:54 EDT 2014

Powered by FUDForum. Page generated in 0.01526 seconds