From 468b267617795fe4c51ccb139e5d85d39f39a791 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 2 Dec 2020 19:49:33 +0100 Subject: 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. --- .../linking/ApplicationConfigurationLinkingService.xtend | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Application') 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 { } private def getByUri(EObject context, EReference ref, INode node) { + val linkedObjects = super.getLinkedObjects(context, ref, node) + if (!linkedObjects.empty) { + return linkedObjects + } val uri = getNSUri(node) if (uri.present) { var URI createdURI try { createdURI = URI.createURI(uri.get) } catch (IllegalArgumentException e) { - return super.getLinkedObjects(context, ref, node) + return #[] } var Resource res try { res = context.eResource.resourceSet.getResource(createdURI, true); } catch (RuntimeException e) { - return super.getLinkedObjects(context, ref, node) + return #[] } if (res !== null && res.contents !== null) { return res.contents.filter[ref.EType.isInstance(it)].toList - } else { - return super.getLinkedObjects(context, ref, node) } - } else { - return super.getLinkedObjects(context, ref, node) } + return #[] } private def getNSUri(INode node) { -- cgit v1.2.3-54-g00ecf