aboutsummaryrefslogtreecommitdiffstats
path: root/Application
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-12-02 19:49:33 +0100
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-12-02 19:49:33 +0100
commit468b267617795fe4c51ccb139e5d85d39f39a791 (patch)
tree612b3df3453a480e87e9ee2b27e9514a548d83a0 /Application
parentMerge branch 'master' of github.com:viatra/VIATRA-Generator (diff)
downloadVIATRA-Generator-468b267617795fe4c51ccb139e5d85d39f39a791.tar.gz
VIATRA-Generator-468b267617795fe4c51ccb139e5d85d39f39a791.tar.zst
VIATRA-Generator-468b267617795fe4c51ccb139e5d85d39f39a791.zip
Prefer the global scope insted of nsURI in application configuration
Trying to find a resource by nsURI first sometimes lead to a situation where a spurious resource was added to the ResourceSet which didn't contain the requested object. Thus, linking failed. By first looking up the imported name in the global scope and falling back to the nsURI only later, we can ensure that linking always succeeds if the referenced object is already in the Xtext index.
Diffstat (limited to 'Application')
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend13
1 files changed, 7 insertions, 6 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend
index fafba1d7..c876f3be 100644
--- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend
+++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend
@@ -71,28 +71,29 @@ class ApplicationConfigurationLinkingService extends DefaultLinkingService {
71 } 71 }
72 72
73 private def getByUri(EObject context, EReference ref, INode node) { 73 private def getByUri(EObject context, EReference ref, INode node) {
74 val linkedObjects = super.getLinkedObjects(context, ref, node)
75 if (!linkedObjects.empty) {
76 return linkedObjects
77 }
74 val uri = getNSUri(node) 78 val uri = getNSUri(node)
75 if (uri.present) { 79 if (uri.present) {
76 var URI createdURI 80 var URI createdURI
77 try { 81 try {
78 createdURI = URI.createURI(uri.get) 82 createdURI = URI.createURI(uri.get)
79 } catch (IllegalArgumentException e) { 83 } catch (IllegalArgumentException e) {
80 return super.getLinkedObjects(context, ref, node) 84 return #[]
81 } 85 }
82 var Resource res 86 var Resource res
83 try { 87 try {
84 res = context.eResource.resourceSet.getResource(createdURI, true); 88 res = context.eResource.resourceSet.getResource(createdURI, true);
85 } catch (RuntimeException e) { 89 } catch (RuntimeException e) {
86 return super.getLinkedObjects(context, ref, node) 90 return #[]
87 } 91 }
88 if (res !== null && res.contents !== null) { 92 if (res !== null && res.contents !== null) {
89 return res.contents.filter[ref.EType.isInstance(it)].toList 93 return res.contents.filter[ref.EType.isInstance(it)].toList
90 } else {
91 return super.getLinkedObjects(context, ref, node)
92 } 94 }
93 } else {
94 return super.getLinkedObjects(context, ref, node)
95 } 95 }
96 return #[]
96 } 97 }
97 98
98 private def getNSUri(INode node) { 99 private def getNSUri(INode node) {