|
@@ -10,10 +10,15 @@
|
|
|
*/
|
|
|
package org.yakindu.sct.generator.builder.efs;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
+import org.eclipse.core.resources.IFile;
|
|
|
import org.eclipse.core.resources.IProject;
|
|
|
import org.eclipse.core.resources.IWorkspace;
|
|
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
|
+import org.eclipse.emf.common.util.URI;
|
|
|
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
|
|
|
+import org.eclipse.xtext.generator.OutputConfiguration;
|
|
|
import org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess;
|
|
|
|
|
|
import com.google.inject.Inject;
|
|
@@ -38,5 +43,23 @@ public class SCTEclipseResourceFileSystemAccess extends EclipseResourceFileSyste
|
|
|
IProject project = ws.getRoot().getProject(projectName);
|
|
|
super.setProject(project);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public URI getURI(String path, String outputConfiguration) {
|
|
|
+ OutputConfiguration outputConfig = getOutputConfig(outputConfiguration);
|
|
|
+ String outputDir = outputConfig.getOutputDirectory();
|
|
|
+ if (isRootPath(outputDir) && isRootPath(path)) {
|
|
|
+ return URI.createFileURI(getProject().getLocationURI().getPath());
|
|
|
+ }
|
|
|
+ IFile file = getProject().getFile(outputDir + File.separator + path);
|
|
|
+ if (file != null) {
|
|
|
+ return URI.createFileURI(file.getLocationURI().getPath());
|
|
|
+ }
|
|
|
+ return super.getURI(path);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected boolean isRootPath(String path) {
|
|
|
+ return (".".equals(path) || "/".equals(path) || "./".equals(path) || "".equals(path));
|
|
|
+ }
|
|
|
|
|
|
}
|