Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-02-08 04:13:33 -0500
committerHenrik Rentz-Reichert2012-02-08 04:13:33 -0500
commitef62a30fab78d64698f58cb4eeab1d298bed8f56 (patch)
tree4a8fd917cd9851dc4d7b1ab357620ac0f9ce8c67 /plugins
parentbc1ff1fc3201ab2be207b51f29a4dee56d4fa121 (diff)
downloadorg.eclipse.etrice-ef62a30fab78d64698f58cb4eeab1d298bed8f56.tar.gz
org.eclipse.etrice-ef62a30fab78d64698f58cb4eeab1d298bed8f56.tar.xz
org.eclipse.etrice-ef62a30fab78d64698f58cb4eeab1d298bed8f56.zip
[generator, generator.launch] improved uri handling
using file uris, absolute and relative - no file: scheme
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/PlatformRelativeUriResolver.java11
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java26
3 files changed, 33 insertions, 6 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/PlatformRelativeUriResolver.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/PlatformRelativeUriResolver.java
index 57668672f..6fdec2854 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/PlatformRelativeUriResolver.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/PlatformRelativeUriResolver.java
@@ -88,12 +88,19 @@ public class PlatformRelativeUriResolver extends ImportUriResolver {
URI base = baseUri.trimSegments(1);
if (base.isPlatformResource()) {
IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(base.toPlatformString(true)));
- // URI.resolve expects a trailing separator for some reason...
String abs = folder.getRawLocationURI().toString();
base = URI.createURI(abs);
}
+ else if (base.isRelative()) {
+ base = URI.createFileURI(new File(base.toString()).getAbsolutePath());
+ }
+ // URI.resolve expects a trailing separator for some reason...
base = base.appendSegment("");
- uri = uri.resolve(base);
+ try {
+ uri = uri.resolve(base);
+ }
+ catch (IllegalArgumentException e) {
+ }
resolve = uri.toString();
File file = new File(uri.toFileString());
if (file.isDirectory())
diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
index b578f8d4a..45c7ecdf9 100644
--- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
@@ -152,7 +152,7 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
@SuppressWarnings("unchecked")
ArrayList<String> models = (ArrayList<String>) configuration.getAttribute("ModelFiles", Collections.EMPTY_LIST);
for (String model : models){
- argString.append(" file://"+model);
+ argString.append(" "+model);
}
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index b555826b0..4fad680c9 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -12,6 +12,7 @@
package org.eclipse.etrice.generator.base;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -23,6 +24,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.scoping.PlatformRelativeUriResolver;
import org.eclipse.etrice.generator.builder.GeneratorModelBuilder;
import org.eclipse.etrice.generator.etricegen.IDiagnostician;
import org.eclipse.etrice.generator.etricegen.Root;
@@ -84,6 +86,9 @@ public abstract class AbstractGenerator {
@Inject
protected JavaIoFileSystemAccess fileAccess;
+ @Inject
+ protected PlatformRelativeUriResolver uriResolver;
+
protected IResourceValidator validator;
/**
@@ -176,6 +181,21 @@ public abstract class AbstractGenerator {
return true;
}
+ protected boolean loadModel(String uriString, ResourceSet rs)
+ throws RuntimeException, IOException {
+ String can = URI.createFileURI(uriString).toFileString();
+ File f = new File(can);
+ can = f.getCanonicalPath(); // e.g. remove embedded ../
+ if (rs.getResource(URI.createFileURI(can), false) != null)
+ // already loaded
+ return false;
+
+ logger.logInfo("Loading " + can);
+ rs.getResource(URI.createFileURI(can), true); // Could throw an exception...
+ return true;
+ }
+
+
/**
* load all models into a {@link ResourceSet}
*
@@ -186,11 +206,11 @@ public abstract class AbstractGenerator {
logger.logInfo("-- reading models");
boolean ok = true;
for (String uriString : uriList) {
- logger.logInfo("Loading " + uriString);
+ //logger.logInfo("Loading " + uriString);
try {
- rs.getResource(URI.createURI(uriString), true);
+ loadModel(uriString,rs);
}
- catch (RuntimeException e) {
+ catch (Exception e) {
ok = false;
logger.logError("couldn't load '"+uriString+"'", null);
}

Back to the top