|
Re: Multiple QualifiedProviders within a DSL language [message #1809465 is a reply to message #1809454] |
Tue, 16 July 2019 13:54 |
|
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
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Re: Multiple QualifiedProviders within a DSL language [message #1809844 is a reply to message #1809725] |
Wed, 24 July 2019 14:30 |
Nicky van Oorschot 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 #1809895 is a reply to message #1809873] |
Thu, 25 July 2019 11:16 |
|
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('.',':');
}
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03547 seconds