diff options
Diffstat (limited to 'org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/resource/ProblemResourceDescriptionStrategy.java')
-rw-r--r-- | org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/resource/ProblemResourceDescriptionStrategy.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/resource/ProblemResourceDescriptionStrategy.java b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/resource/ProblemResourceDescriptionStrategy.java new file mode 100644 index 00000000..7b37ffd6 --- /dev/null +++ b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/resource/ProblemResourceDescriptionStrategy.java | |||
@@ -0,0 +1,39 @@ | |||
1 | package org.eclipse.viatra.solver.language.resource; | ||
2 | |||
3 | import org.eclipse.emf.ecore.EObject; | ||
4 | import org.eclipse.viatra.solver.language.model.problem.ReferenceDeclaration; | ||
5 | import org.eclipse.viatra.solver.language.model.problem.Variable; | ||
6 | import org.eclipse.xtext.naming.QualifiedName; | ||
7 | import org.eclipse.xtext.resource.IEObjectDescription; | ||
8 | import org.eclipse.xtext.resource.impl.AliasedEObjectDescription; | ||
9 | import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy; | ||
10 | import org.eclipse.xtext.util.IAcceptor; | ||
11 | |||
12 | import com.google.inject.Singleton; | ||
13 | |||
14 | @Singleton | ||
15 | public class ProblemResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy { | ||
16 | @Override | ||
17 | public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { | ||
18 | IAcceptor<IEObjectDescription> wrappedAcceptor; | ||
19 | if (eObject instanceof Variable) { | ||
20 | return false; | ||
21 | } | ||
22 | if (eObject instanceof ReferenceDeclaration) { | ||
23 | wrappedAcceptor = new IAcceptor<IEObjectDescription>() { | ||
24 | public void accept(IEObjectDescription description) { | ||
25 | acceptor.accept(description); | ||
26 | QualifiedName qualifiedName = description.getQualifiedName(); | ||
27 | if (qualifiedName.getSegmentCount() >= 2) { | ||
28 | QualifiedName simpleName = QualifiedName.create(qualifiedName.getLastSegment()); | ||
29 | IEObjectDescription aliasedDescription = new AliasedEObjectDescription(simpleName, description); | ||
30 | acceptor.accept(aliasedDescription); | ||
31 | } | ||
32 | }; | ||
33 | }; | ||
34 | } else { | ||
35 | wrappedAcceptor = acceptor; | ||
36 | } | ||
37 | return super.createEObjectDescriptions(eObject, wrappedAcceptor); | ||
38 | } | ||
39 | } | ||