diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-02-04 22:06:56 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-02-04 22:06:56 +0100 |
commit | 4dd2b4e1f45bf940d969181ae9b9176fa353c92e (patch) | |
tree | 72e315d726014966d8c701686962bfb5fbdea5a7 /subprojects/language-semantics/src/main | |
parent | feat(language): import resolution (diff) | |
download | refinery-4dd2b4e1f45bf940d969181ae9b9176fa353c92e.tar.gz refinery-4dd2b4e1f45bf940d969181ae9b9176fa353c92e.tar.zst refinery-4dd2b4e1f45bf940d969181ae9b9176fa353c92e.zip |
feat: filesystem-level import resolution
Modules without an explicitly declared name get a name automatically inferred
from their path.
Diffstat (limited to 'subprojects/language-semantics/src/main')
-rw-r--r-- | subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/SolutionSerializer.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/SolutionSerializer.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/SolutionSerializer.java index 1bd419d8..dad867b8 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/SolutionSerializer.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/SolutionSerializer.java | |||
@@ -19,6 +19,7 @@ import org.eclipse.xtext.resource.XtextResource; | |||
19 | import org.eclipse.xtext.resource.XtextResourceSet; | 19 | import org.eclipse.xtext.resource.XtextResourceSet; |
20 | import org.eclipse.xtext.scoping.IScopeProvider; | 20 | import org.eclipse.xtext.scoping.IScopeProvider; |
21 | import tools.refinery.language.model.problem.*; | 21 | import tools.refinery.language.model.problem.*; |
22 | import tools.refinery.language.scoping.imports.ImportAdapter; | ||
22 | import tools.refinery.language.utils.ProblemDesugarer; | 23 | import tools.refinery.language.utils.ProblemDesugarer; |
23 | import tools.refinery.language.utils.ProblemUtil; | 24 | import tools.refinery.language.utils.ProblemUtil; |
24 | import tools.refinery.store.model.Model; | 25 | import tools.refinery.store.model.Model; |
@@ -79,7 +80,7 @@ public class SolutionSerializer { | |||
79 | } | 80 | } |
80 | 81 | ||
81 | public Problem serializeSolution(ProblemTrace trace, Model model) { | 82 | public Problem serializeSolution(ProblemTrace trace, Model model) { |
82 | var uri = URI.createFileURI("__synthetic" + fileExtension); | 83 | var uri = URI.createURI("__synthetic." + fileExtension); |
83 | return serializeSolution(trace, model, uri); | 84 | return serializeSolution(trace, model, uri); |
84 | } | 85 | } |
85 | 86 | ||
@@ -133,6 +134,7 @@ public class SolutionSerializer { | |||
133 | 134 | ||
134 | private Problem copyProblem(Problem originalProblem, URI uri) { | 135 | private Problem copyProblem(Problem originalProblem, URI uri) { |
135 | var newResourceSet = resourceSetProvider.get(); | 136 | var newResourceSet = resourceSetProvider.get(); |
137 | ImportAdapter.copySettings(originalProblem, newResourceSet); | ||
136 | if (!fileExtension.equals(uri.fileExtension())) { | 138 | if (!fileExtension.equals(uri.fileExtension())) { |
137 | uri = uri.appendFileExtension(fileExtension); | 139 | uri = uri.appendFileExtension(fileExtension); |
138 | } | 140 | } |
@@ -153,6 +155,7 @@ public class SolutionSerializer { | |||
153 | throw new IllegalStateException("Failed to copy problem", e); | 155 | throw new IllegalStateException("Failed to copy problem", e); |
154 | } | 156 | } |
155 | var contents = newResource.getContents(); | 157 | var contents = newResource.getContents(); |
158 | EcoreUtil.resolveAll(newResourceSet); | ||
156 | if (!contents.isEmpty() && contents.getFirst() instanceof Problem newProblem) { | 159 | if (!contents.isEmpty() && contents.getFirst() instanceof Problem newProblem) { |
157 | return newProblem; | 160 | return newProblem; |
158 | } | 161 | } |