diff options
author | Jan Belle | 2021-05-20 22:51:03 +0000 |
---|---|---|
committer | Jan Belle | 2021-05-21 08:56:45 +0000 |
commit | ba6d32f530430f0bec5e162cfa801d9dff999a7b (patch) | |
tree | fddcb5eac3002df98e706d655c40d57ccb53d416 | |
parent | 09b10cb162919a94bb713cd2fd395b5bece7e69f (diff) | |
download | org.eclipse.etrice-ba6d32f530430f0bec5e162cfa801d9dff999a7b.tar.gz org.eclipse.etrice-ba6d32f530430f0bec5e162cfa801d9dff999a7b.tar.xz org.eclipse.etrice-ba6d32f530430f0bec5e162cfa801d9dff999a7b.zip |
[core.common] Remove obsolete uri resolution steps
If Eclipse is running we use platform uris and normalized file uris
otherwise. Therefore we can eliminate uri resolution everywhere except
for import statements with uris.
Change-Id: I613aeb933b1d18c6dbbf2512eef67bf7289ab04c
17 files changed, 78 insertions, 73 deletions
diff --git a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathResourceSetInitializer.java b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathResourceSetInitializer.java index 752887798..4dad9e66c 100644 --- a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathResourceSetInitializer.java +++ b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/modelpath/ModelPathResourceSetInitializer.java @@ -35,7 +35,7 @@ public class ModelPathResourceSetInitializer implements IResourceSetInitializer public void initialize(ResourceSet resourceSet, IProject project) { if(project != null) { ModelPathDelegate modelPath = new ModelPathDelegate(project); - resourceSet.getLoadOptions().put(ResourceSetModelPathProvider.LOAD_OPTION_MODELPATH, modelPath); + ResourceSetModelPathProvider.install(resourceSet, modelPath); } } diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/ModelPathGlobalScopeProvider.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/ModelPathGlobalScopeProvider.java index c35d7f337..0a39aa047 100644 --- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/ModelPathGlobalScopeProvider.java +++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/ModelPathGlobalScopeProvider.java @@ -20,7 +20,9 @@ import java.util.stream.Stream; import java.util.stream.Stream.Builder; import java.util.stream.StreamSupport; +import org.apache.log4j.Logger; import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.common.util.WrappedException; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; @@ -48,6 +50,8 @@ import com.google.inject.Inject; */ public class ModelPathGlobalScopeProvider extends AbstractGlobalScopeProvider { + private static final Logger LOG = Logger.getLogger(ModelPathGlobalScopeProvider.class); + /** * Filters the model files. */ @@ -58,16 +62,14 @@ public class ModelPathGlobalScopeProvider extends AbstractGlobalScopeProvider { private IQualifiedNameProvider qualifiedNameProvider; private IResourceServiceProvider.Registry resourceServiceProviderRegistry; private IModelPathFileFilter modelPathFileFilter; - private ModelLocatorUriResolver uriResolver; @Inject public ModelPathGlobalScopeProvider(IModelPathProvider modelPathProvider, IQualifiedNameProvider qualifiedNameProvider, - IResourceServiceProvider.Registry resourceServiceProviderRegistry, IModelPathFileFilter modelPathFileFilter, ModelLocatorUriResolver uriResolver) { + IResourceServiceProvider.Registry resourceServiceProviderRegistry, IModelPathFileFilter modelPathFileFilter) { this.modelPathProvider = modelPathProvider; this.qualifiedNameProvider = qualifiedNameProvider; this.resourceServiceProviderRegistry = resourceServiceProviderRegistry; this.modelPathFileFilter = modelPathFileFilter; - this.uriResolver = uriResolver; } @Override @@ -193,7 +195,6 @@ public class ModelPathGlobalScopeProvider extends AbstractGlobalScopeProvider { * @return an optional of the requested resource descriptions */ private Stream<IResourceDescription> getResourceDescription(URI uri, IResourceDescriptions descriptions, ResourceSet resourceSet) { - uri = resolveURI(uri); IResourceDescription resourceDescription = descriptions.getResourceDescription(uri); if(resourceDescription != null) { return Stream.of(resourceDescription); @@ -201,19 +202,22 @@ public class ModelPathGlobalScopeProvider extends AbstractGlobalScopeProvider { else { IResourceServiceProvider resourceServiceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(uri); if(resourceServiceProvider != null) { - Resource resource = resourceSet.getResource(uri, true); - IResourceDescription.Manager descriptionManager = resourceServiceProvider.getResourceDescriptionManager(); - resourceDescription = descriptionManager.getResourceDescription(resource); - return Stream.of(resourceDescription); + try { + Resource resource = resourceSet.getResource(uri, true); + IResourceDescription.Manager descriptionManager = resourceServiceProvider.getResourceDescriptionManager(); + resourceDescription = descriptionManager.getResourceDescription(resource); + return Stream.of(resourceDescription); + } + catch(WrappedException e) { + LOG.error("Failed to load " + uri + "; " + e.getMessage()); + } + } + else { + LOG.error("Missing resource service provider for uri " + uri); } } return Stream.empty(); } - - private URI resolveURI(URI uri) { - String uriStr = uriResolver.resolve(uri.toString(), null); - return URI.createURI(uriStr); - } } private static final class FileDescriptionPair { diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java index 18292a02f..555e24b42 100644 --- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java +++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java @@ -30,6 +30,7 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.etrice.generator.base.io.NIOPathUtil; import org.eclipse.xtext.resource.ClasspathUriResolutionException; /** @@ -333,9 +334,9 @@ public class StandardModelLocator implements IModelLocator { // now we give the super class a chance to locate the model file f = locateFile(f); - can = f.getCanonicalPath(); // e.g. remove embedded ../ - URI canonical = URI.createFileURI(can); - return canonical; + File canonical = f.getCanonicalFile(); // e.g. remove embedded ../ + URI canonicalUri = NIOPathUtil.toEMFUri(canonical.toPath()); + return canonicalUri; } return normalized; diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/FileSystemModelPath.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/FileSystemModelPath.java index 42705cf10..a5fe0d5ce 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/FileSystemModelPath.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/FileSystemModelPath.java @@ -123,7 +123,7 @@ public class FileSystemModelPath implements IModelPath { * @return the new model file */ private ModelFile createModelFile(Path file, QualifiedName pkg) { - URI uri = URI.createURI(file.toUri().toString()); + URI uri = NIOPathUtil.toEMFUri(file); String fileName = file.getFileName().toString(); return ModelFile.create(uri, pkg, fileName); } @@ -179,12 +179,11 @@ public class FileSystemModelPath implements IModelPath { private Optional<Path> toFilePath(URI uri) { if(uri.isFile()) { /* - * If the authority of the uri is non-empty, - * URI.toFileString produces a file string containing the authority that can't be parsed by Paths.get. - * So we create the path directly from the device and segments of the uri and convert it to an absolute path if necessary. + * If the authority of a uri is non-empty, URI.toFileString produces a file string + * containing the authority that can't be parsed by Path.of. + * Therefore we take the detour via java.net.URI. */ - Path path = Paths.get(uri.hasDevice() ? uri.device() : "", uri.segments()); - return Optional.of(uri.hasAbsolutePath() ? path.toAbsolutePath() : path); + return Optional.of(Path.of(java.net.URI.create(uri.toString()))); } return Optional.empty(); } diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java index 73768ee7b..9c7d2d5f6 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java @@ -70,7 +70,7 @@ public class GeneratorResourceLoader implements IGeneratorResourceLoader { resourceSet.eAdapters().add(resourceAddedAdapter); IModelPath mp = createModelPath(modelpath, logger); - resourceSet.getLoadOptions().putIfAbsent(ResourceSetModelPathProvider.LOAD_OPTION_MODELPATH, mp); + ResourceSetModelPathProvider.install(resourceSet, mp); List<Resource> resources = loadResources(files, resourceSet, logger); @@ -99,7 +99,7 @@ public class GeneratorResourceLoader implements IGeneratorResourceLoader { Path normalizedPath = Paths.get(file).normalize(); if(Files.exists(normalizedPath)) { Path realPath = toRealPath(normalizedPath); - URI uri = createURI(realPath); + URI uri = NIOPathUtil.toEMFUri(realPath); try { return rs.getResource(uri, true); } @@ -152,10 +152,6 @@ public class GeneratorResourceLoader implements IGeneratorResourceLoader { } } - protected URI createURI(Path path) { - return URI.createURI(path.toUri().toString()); - } - private Path toRealPath(Path path, LinkOption... options) { try { return path.toRealPath(options); diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/NIOPathUtil.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/NIOPathUtil.java new file mode 100644 index 000000000..32938a2bb --- /dev/null +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/NIOPathUtil.java @@ -0,0 +1,40 @@ +/******************************************************************************* +* Copyright (c) 2021 protos software gmbh (http://www.protos.de). +* All rights reserved. +* +* This program and the accompanying materials are made +* available under the terms of the Eclipse Public License 2.0 +* which is available at https://www.eclipse.org/legal/epl-2.0/ +* +* SPDX-License-Identifier: EPL-2.0 +* +* CONTRIBUTORS: +* Jan Belle (initial contribution) +* + *******************************************************************************/ + +package org.eclipse.etrice.generator.base.io; + +import java.nio.file.Path; + +import org.eclipse.emf.common.util.URI; + +/** + * Utility class for {@link java.nio.Path} + */ +public class NIOPathUtil { + + /** + * Convert a path object to an emf uri. If the authority is absent an empty authority is added. + * + * @param path the path to convert + * @return an emf uri representing the path + */ + public static URI toEMFUri(Path path) { + URI uri = URI.createURI(path.toUri().toString()); + if(uri.isFile() && !uri.hasAuthority()) + return URI.createHierarchicalURI(uri.scheme(), "", uri.device(), uri.segments(), uri.query(), uri.fragment()); + return uri; + } + +} diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/ResourceSetModelPathProvider.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/ResourceSetModelPathProvider.java index 0bc4fc72c..f7575722a 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/ResourceSetModelPathProvider.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/ResourceSetModelPathProvider.java @@ -23,7 +23,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet; */ public class ResourceSetModelPathProvider implements IModelPathProvider { - public static final String LOAD_OPTION_MODELPATH = "org.eclipse.etrice.generator.base.modelpath"; + private static final String LOAD_OPTION_MODELPATH = "org.eclipse.etrice.generator.base.modelpath"; @Override public IModelPath get(Resource resource) { @@ -35,4 +35,7 @@ public class ResourceSetModelPathProvider implements IModelPathProvider { return IModelPath.EMPTY; } + public static void install(ResourceSet resourceSet, IModelPath modelpath) { + resourceSet.getLoadOptions().put(LOAD_OPTION_MODELPATH, modelpath); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend index 01a36c9ef..108aadd3b 100644 --- a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend +++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend @@ -38,7 +38,6 @@ import org.eclipse.etrice.core.room.Attribute import org.eclipse.etrice.core.room.ProtocolClass import org.eclipse.etrice.generator.base.IDataConfiguration import org.eclipse.etrice.generator.config.util.DataConfigurationHelper -import org.eclipse.xtext.scoping.impl.ImportUriResolver class DataConfiguration implements IDataConfiguration { @@ -48,9 +47,6 @@ class DataConfiguration implements IDataConfiguration { @Inject protected ILogger logger; - @Inject - protected ImportUriResolver uriResolver; - override doSetup() { if (!EMFPlugin::IS_ECLIPSE_RUNNING) ConfigStandaloneSetup::doSetup() diff --git a/plugins/org.eclipse.etrice.generator.contractmonitor/src/org/eclipse/etrice/generator/contractmonitor/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.contractmonitor/src/org/eclipse/etrice/generator/contractmonitor/setup/GeneratorModule.java index efbb8e8ff..3555e7dde 100644 --- a/plugins/org.eclipse.etrice.generator.contractmonitor/src/org/eclipse/etrice/generator/contractmonitor/setup/GeneratorModule.java +++ b/plugins/org.eclipse.etrice.generator.contractmonitor/src/org/eclipse/etrice/generator/contractmonitor/setup/GeneratorModule.java @@ -32,9 +32,7 @@ import org.eclipse.etrice.generator.base.EMFSetup; import org.eclipse.etrice.generator.base.GenerationEMFDiagnostician; import org.eclipse.etrice.generator.base.IGenerator; import org.eclipse.etrice.generator.base.ITranslationProvider; -import org.eclipse.etrice.generator.base.ModelLoader; import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup; -import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader; import org.eclipse.etrice.generator.base.setup.GeneratorName; import org.eclipse.etrice.generator.base.setup.GeneratorOptions; import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator; @@ -60,7 +58,6 @@ public class GeneratorModule implements Module { // TODO this should be a common module in etrice binder.bind(IGeneratorEMFSetup.class).to(EMFSetup.class); - binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class); // binder.bind(IGeneratorResourceValidator.class).to(ModelValidator.class); binder.bind(IGenerator.class).to(Main.class); binder.bind(ResourceSet.class).to(XtextResourceSet.class); diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java index defd54cbb..4c8e6abde 100644 --- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java +++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/setup/GeneratorModule.java @@ -14,7 +14,6 @@ package org.eclipse.etrice.generator.cpp.setup; -import org.eclipse.etrice.core.common.scoping.ModelLocatorUriResolver; import org.eclipse.etrice.generator.base.AbstractGenerator; import org.eclipse.etrice.generator.base.AbstractGeneratorBaseModule; import org.eclipse.etrice.generator.base.AbstractGeneratorOptions; @@ -30,7 +29,6 @@ import org.eclipse.etrice.generator.generic.GenericActorClassGenerator; import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator; import org.eclipse.etrice.generator.generic.ILanguageExtension; import org.eclipse.etrice.generator.generic.ProcedureHelpers; -import org.eclipse.xtext.scoping.impl.ImportUriResolver; import com.google.inject.Binder; @@ -43,8 +41,6 @@ public class GeneratorModule extends AbstractGeneratorBaseModule { binder.bind(ProcedureHelpers.class).to(CppProcedureHelpers.class); binder.bind(GenericProtocolClassGenerator.class).to(ProtocolClassGen.class); binder.bind(GenericActorClassGenerator.class).to(ActorClassGen.class); - - binder.bind(ImportUriResolver.class).to(ModelLocatorUriResolver.class); } @Override diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java index e30640d60..757147037 100644 --- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java +++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java @@ -24,10 +24,8 @@ import org.eclipse.etrice.generator.base.EMFSetup; import org.eclipse.etrice.generator.base.GenerationEMFDiagnostician; import org.eclipse.etrice.generator.base.IGenerator; import org.eclipse.etrice.generator.base.ITranslationProvider; -import org.eclipse.etrice.generator.base.ModelLoader; import org.eclipse.etrice.generator.base.ModelValidator; import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup; -import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader; import org.eclipse.etrice.generator.base.setup.GeneratorName; import org.eclipse.etrice.generator.base.setup.GeneratorOptions; import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator; @@ -48,7 +46,6 @@ public class GeneratorModule implements Module { binder.bind(String.class).annotatedWith(GeneratorName.class).toInstance(GENERATOR_NAME); binder.bind(GeneratorOptions.class).to(DocGeneratorOptions.class); binder.bind(IGeneratorEMFSetup.class).to(EMFSetup.class); - binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class); binder.bind(IGeneratorResourceValidator.class).to(ModelValidator.class); binder.bind(IGenerator.class).to(Main.class); diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java index 0a7b7d2d6..5155e3e05 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java +++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java @@ -28,7 +28,6 @@ import org.eclipse.etrice.generator.base.logging.Loglevel; import org.eclipse.etrice.generator.java.gen.MainGen; import org.eclipse.etrice.generator.java.gen.Validator; import org.eclipse.etrice.generator.java.setup.GeneratorModule; -import org.eclipse.xtext.scoping.impl.ImportUriResolver; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -60,9 +59,6 @@ public class Main extends AbstractGenerator { @Inject protected IDataConfiguration dataConfig; - @Inject - protected ImportUriResolver uriResolver; - /* (non-Javadoc) * @see org.eclipse.etrice.generator.base.AbstractGenerator#runGenerator() */ diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java index b6348e751..890b4cb5c 100644 --- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java +++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java @@ -14,7 +14,6 @@ package org.eclipse.etrice.generator.java.setup; -import org.eclipse.etrice.core.common.scoping.ModelLocatorUriResolver; import org.eclipse.etrice.generator.base.AbstractGenerator; import org.eclipse.etrice.generator.base.AbstractGeneratorBaseModule; import org.eclipse.etrice.generator.base.AbstractGeneratorOptions; @@ -28,7 +27,6 @@ import org.eclipse.etrice.generator.java.gen.ActorClassGen; import org.eclipse.etrice.generator.java.gen.JavaExtensions; import org.eclipse.etrice.generator.java.gen.JavaTranslationProvider; import org.eclipse.etrice.generator.java.gen.ProtocolClassGen; -import org.eclipse.xtext.scoping.impl.ImportUriResolver; import com.google.inject.Binder; @@ -41,8 +39,6 @@ public class GeneratorModule extends AbstractGeneratorBaseModule { binder.bind(GenericProtocolClassGenerator.class).to(ProtocolClassGen.class); binder.bind(GenericActorClassGenerator.class).to(ActorClassGen.class); - binder.bind(ImportUriResolver.class).to(ModelLocatorUriResolver.class); - binder.bind(AbstractGeneratorOptions.class).to(GeneratorOptions.class); } 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 a54971414..b1f0e4dcb 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 @@ -189,7 +189,7 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL String substituted = variableManager.performStringSubstitution(model); IFile file = root.getFileForLocation(new Path(substituted)); if(file == null || !file.exists()) - throw new CoreException(new Status(Status.ERROR, getClass().getName(), + throw new CoreException(new Status(Status.ERROR, getClass(), "Failed to find file in workspace: " + substituted)); files.add(file); } diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchHelper.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchHelper.java index cd75b5e59..b973a25f6 100644 --- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchHelper.java +++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchHelper.java @@ -61,8 +61,8 @@ public class GeneratorLaunchHelper { resourceSet.getResource(uri, true); } catch(RuntimeException e) { - throw new CoreException(new Status(Status.ERROR, getClass().getName(), - "Failed to load resource " + uri)); + throw new CoreException(new Status(Status.ERROR, getClass(), + "Failed to load resource " + uri, e)); } } diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java index b5423dfbd..75d531c2c 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java @@ -23,7 +23,6 @@ import org.eclipse.etrice.core.naming.RoomNameProvider; import org.eclipse.etrice.core.room.util.CommonDataCalculator; import org.eclipse.etrice.generator.base.io.GeneratorFileIO; import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup; -import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader; import org.eclipse.etrice.generator.base.logging.Logger; import org.eclipse.etrice.generator.base.setup.GeneratorName; import org.eclipse.etrice.generator.base.setup.GeneratorOptions; @@ -79,7 +78,6 @@ public abstract class AbstractGeneratorBaseModule implements Module { } binder.bind(String.class).annotatedWith(GeneratorName.class).toInstance(bindGeneratorName()); binder.bind(GeneratorOptions.class).to(bindGeneratorOptions()); - binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class); binder.bind(IGeneratorResourceValidator.class).to(ModelValidator.class); binder.bind(Diagnostician.class).in(Singleton.class); binder.bind(IDiagnostician.class).to(Diagnostician.class); diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java index 1e7735a8c..5da7e80f5 100644 --- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java +++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java @@ -14,11 +14,7 @@ package org.eclipse.etrice.generator.base; -import java.nio.file.Path; - -import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.etrice.core.common.scoping.ModelLocatorUriResolver; import org.eclipse.etrice.generator.base.io.GeneratorResourceLoader; import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup; import com.google.inject.Inject; @@ -26,22 +22,12 @@ import com.google.inject.Provider; /** * @author Henrik Rentz-Reichert - * + * @deprecated replaced by {@link GeneratorResourceLoader} */ public class ModelLoader extends GeneratorResourceLoader { - private ModelLocatorUriResolver uriResolver; - @Inject - public ModelLoader(Provider<ResourceSet> resourceSetProvider, IGeneratorEMFSetup emfSetup, ModelLocatorUriResolver uriResolver) { + public ModelLoader(Provider<ResourceSet> resourceSetProvider, IGeneratorEMFSetup emfSetup) { super(resourceSetProvider, emfSetup); - - this.uriResolver = uriResolver; - } - - @Override - protected URI createURI(Path path) { - String uri = uriResolver.resolve(path.toString(), null); - return URI.createURI(uri); } } |