Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple QualifiedProviders within a DSL language
Multiple QualifiedProviders within a DSL language [message #1809454] Tue, 16 July 2019 11:38 Go to next message
Nicky van Oorschot is currently offline Nicky van OorschotFriend
Messages: 4
Registered: July 2019
Junior Member
We are developing a Xtext application/plugin for Eclipse. Within this application we would like to use in addition to standard qualified name referencing with the dot also a custom qualified name which could reference with a colon.
Which will make it possible to have elements which work like: resource.subresource and have elements which work with resource:subresource.

To achieve this we added and registered a custom QualifiedName Provider in the runtime which overrides the "computeFullyQualifiedNameFromNameAttribute" so it could be used with "rdfname" instead of "name" and has a custom QualifiedName Converter which overrides the delimiter method, from "." to ":".
In the Grammer for the elements we would like to use with the custom QualifiedName Provider we added a custom QualifiedName with the colon:

RdfQualifiedName:
	ID (':' ID);


The name attribute is also replaced for the rdfname attribute. But we still get that the reference could not be resolved.

At the moment we actually try to figure out whether it is, or it is not intended that one can have several different types of QualifiedNames with different delimiters within one language?
Re: Multiple QualifiedProviders within a DSL language [message #1809465 is a reply to message #1809454] Tue, 16 July 2019 13:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13124
Registered: July 2009
Senior Member
you can debug org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(EObject, EReference, INode)
places to look at are
- indexing: org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy.createEObjectDescriptions(EObject, IAcceptor<IEObjectDescription>)
- resource scope: org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getQualifiedNameOfLocalElement(EObject)
- customizations to MyDslScopeProvider


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple QualifiedProviders within a DSL language [message #1809723 is a reply to message #1809465] Mon, 22 July 2019 07:24 Go to previous messageGo to next message
Nicky van Oorschot is currently offline Nicky van OorschotFriend
Messages: 4
Registered: July 2019
Junior Member
So, in first place it should be possible to have to different providers working next each other?
Re: Multiple QualifiedProviders within a DSL language [message #1809725 is a reply to message #1809723] Mon, 22 July 2019 07:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13124
Registered: July 2009
Senior Member
i still dont understand the usecase for that.
there should be one that might take the context into account not two.
there is also the other way round
IQualifiedNameConverter
which takes a String and turns it into a qualfied name.
maybe thats the problem in your case


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple QualifiedProviders within a DSL language [message #1809816 is a reply to message #1809725] Tue, 23 July 2019 20:57 Go to previous messageGo to next message
Adrian Gschwend is currently offline Adrian GschwendFriend
Messages: 1
Registered: July 2019
Junior Member
In our use-case we create a DSL for mapping two different worlds: In one world (RDF) we have the concept of a prefixed term, which expands in the end to a full URI.

We would for example write schema:Person to make it more readable but in another serialization this would become a full URI in the form of http:/ /schema.org /Person. Obviously one wants to be able to autocomplete to everything in the schema:... prefix so in the DSL I never want to see the full URI.

However, we then map this prefixed term to a row in a table in SQL, where the tablename.rowname concept makes more sense. So in one world (RDF) colon ":" is the separator while in the other world dot makes more sense. That's why we try to mix them.

Re: Multiple QualifiedProviders within a DSL language [message #1809844 is a reply to message #1809725] Wed, 24 July 2019 14:30 Go to previous messageGo to next message
Nicky van Oorschot is currently offline Nicky van OorschotFriend
Messages: 4
Registered: July 2019
Junior Member
We are currently developing a DSL which is able to generate a conversion mapping. This mappings are going to be used with RDF (https://en.wikipedia.org/wiki/Resource_Description_Framework).

Within RDF we work with prefix constructions which are used instead of full URI`s. Therefore create statement like: "dcterms:identifier".

This statements are really helpful for our users to understand the RDF part of the syntax. Our first thoughts: if we would be able to create a new QualifiedName type RdfQualifiedName we would be able to use the standard QualifiedName for the non RDF trival parts and we would be able to use the RdfQualifiedName for the RDF Parts.

My first try was creating a custom name converter:

class RdfQualifiedNameConverter extends IQualifiedNameConverter.DefaultImpl {
	override String getDelimiter() { 
			return ":";
	}
}


And in the grammer add:
RdfQualifiedName:
    ID (':' ID);


However, this did not work out. Only the RdfQualified names did work so only with the ":" delimiter, not with the "." delimiter anymore. Than the idea raised we had to add a provider because the standard qualified name probably works on the "name" attribtute. With a custom provider we are able to point the RdfQualifiedName to the custom "rdfname" attribute, but this did not work as well, since we only got a "Couldn't resolve reference" error.

[Updated on: Wed, 24 July 2019 14:44]

Report message to a moderator

Re: Multiple QualifiedProviders within a DSL language [message #1809846 is a reply to message #1809844] Wed, 24 July 2019 15:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13124
Registered: July 2009
Senior Member
Please provide a complete hello world example showing the problem

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple QualifiedProviders within a DSL language [message #1809873 is a reply to message #1809846] Thu, 25 July 2019 08:12 Go to previous messageGo to next message
Nicky van Oorschot is currently offline Nicky van OorschotFriend
Messages: 4
Registered: July 2019
Junior Member
I have created a hello world example: https://gofile.io/?c=EuIR7h
In this example I added the name converter as mentioned above. I also added the custom qualified name provider but the registration is commented out in the runtime module.

The grammer applied (as we would like to use but no runs in errors:

vocabulary vocab1 {
	properties 
		test1
		test2
}

vocabulary vocab2 {
	properties 
		test1
		test2
}

source-group database {
	source table1 {
		type "some type"
	}
}

mapping testMapping from database.table1 {
	properties 
		vocab1:test1
		vocab1:test2
		vocab2:test1
		vocab2:test2
}
Re: Multiple QualifiedProviders within a DSL language [message #1809895 is a reply to message #1809873] Thu, 25 July 2019 11:16 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13124
Registered: July 2009
Senior Member
so you want to use both in the same file: . and :
in this case you might have to digg into the places where this is used.
or you try to use a value converter instead of changing the qualified name converter. i am not sure if is consequently used at all places though

package com.helloworld.mydsl;

import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverter;
import org.eclipse.xtext.conversion.ValueConverter;
import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.nodemodel.INode;

import com.google.inject.Inject;

public class MyDslConverters extends DefaultTerminalConverters {
	
	@Inject
	private RdfQualifiedNameConverter rdfQualifiedNameConverter;

	@ValueConverter(rule = "RdfQualifiedName")
	public IValueConverter<String> RdfQualifiedName() {
		return rdfQualifiedNameConverter;
	}
	
	public static class RdfQualifiedNameConverter implements IValueConverter<String> {

		@Override
		public String toValue(String string, INode node) throws ValueConverterException {
			return string.replaceAll(":", ".");
		}

		@Override
		public String toString(String value) throws ValueConverterException {
			return value.replace('.',':');
		}
		
	}

}



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Indent block of statements
Next Topic:Access to the fields of a package (Tree structure)
Goto Forum:
  


Current Time: Thu Sep 19 05:22:05 GMT 2019

Powered by FUDForum. Page generated in 0.03627 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top