Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths to resources in .dsl file not updated when the project is renamed #70

Closed
echebbi opened this issue Sep 24, 2019 · 1 comment · Fixed by #132
Closed

Paths to resources in .dsl file not updated when the project is renamed #70

echebbi opened this issue Sep 24, 2019 · 1 comment · Fixed by #132
Assignees

Comments

@echebbi
Copy link
Collaborator

echebbi commented Sep 24, 2019

Background

The .dsl file is used to express bindings between a metamodel (an .ecore file) and its semantic (an .ale file). By default (or at least that's what is done in example projects) absolute paths are used to identify the corresponding resources:

syntax=platform:/resource/helloworld/model/helloworld.ecore
behavior=platform:/resource/helloworld/model/helloworld.ale

Expected behavior

When an ALE project is renamed, the path to these files should be updated as well.

Current behavior

When an ALE project is renamed, the .dsl file is left untouched, which leads to runtime exceptions when one attempts to run the interpreter:

Exception in thread "Aql eval thread" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.core.internal.resources.ResourceException: Resource '/helloworld/model/helloworld.ecore' does not exist.
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
	at org.eclipse.emf.ecoretools.ale.core.parser.DslBuilder.load(DslBuilder.java:139)
	at org.eclipse.emf.ecoretools.ale.core.parser.DslBuilder.lambda$0(DslBuilder.java:63)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at org.eclipse.emf.ecoretools.ale.core.parser.DslBuilder.parse(DslBuilder.java:62)
	at org.eclipse.emf.ecoretools.ale.ALEInterpreter.eval(ALEInterpreter.java:186)
	at org.eclipse.emf.ecoretools.ale.ide.ui.launchconfig.RunModelAction$1$1.run(RunModelAction.java:97)
Caused by: org.eclipse.core.internal.resources.ResourceException: Resource '/helloworld/model/helloworld.ecore' does not exist.
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:327)
	at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:201)
	at org.eclipse.core.internal.resources.File.getContents(File.java:275)
	at org.eclipse.core.internal.resources.File.getContents(File.java:268)
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl$WorkbenchHelper.createPlatformResourceInputStream(PlatformResourceURIHandlerImpl.java:207)
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createInputStream(PlatformResourceURIHandlerImpl.java:525)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1314)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 8 more
Caused by: java.lang.Exception: Resource '/helloworld/model/helloworld.ecore' does not exist.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:39)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:35)
	... 18 more

Solution

I never tried, but it looks like using Rename Participants could provide an efficient solution.

@dvojtise
Copy link
Contributor

This is also related to #52
if it was available your dsl file would have reported an error.

@echebbi echebbi self-assigned this May 7, 2020
echebbi added a commit that referenced this issue May 7, 2020
Because:
 - renaming a project or a container is likely to corrupt the whole ALE environment

How:
 - a RenameParticipant listens for renaming events and triggers:
    - a change that updates paths to resources in .dsl files
    - a change that updates paths to resources in project's preferences

Side changes:
 - AleAware.getEnvironment() does not return a Normalized instance anymore.
   Normalized was turning each behavior URI into an absolute file path, making
   code in Rename participants cumbersome.
   DslBuilder is instead charged of turning URI into files before feeding them to ANTLR.

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
echebbi added a commit that referenced this issue May 7, 2020
Because:
 - renaming a project or a container is likely to corrupt the whole ALE environment

How:
 - a RenameParticipant listens for renaming events and triggers:
    - a change that updates paths to resources in .dsl files
    - a change that updates paths to resources in project's preferences

Side changes:
 - AleAware.getEnvironment() does not return a Normalized instance anymore.
   Normalized was turning each behavior URI into an absolute file path, making
   code in Rename participants cumbersome.
   DslBuilder is instead charged of turning URI into files before feeding them to ANTLR.

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
echebbi added a commit that referenced this issue May 7, 2020
Because:
 - renaming a project or a container is likely to corrupt the whole ALE environment

How:
 - a RenameParticipant listens for renaming events and triggers:
    - a change that updates paths to resources in .dsl files
    - a change that updates paths to resources in project's preferences

Side changes:
 - AleAware.getEnvironment() does not return a Normalized instance anymore.
   Normalized was turning each behavior URI into an absolute file path, making
   code in Rename participants cumbersome.
   DslBuilder is instead charged of turning URI into files before feeding them to ANTLR.

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants