|
Re: Using ImportURIScopingFragment instead of ImportNamespacesScopingFragment with the new MWE2 [message #1736351 is a reply to message #1736350] |
Tue, 28 June 2016 17:47   |
Eclipse User |
|
|
|
the use of import uri scoping is kind a discouraged. thus there is no new fragment supporting it.
what about leaving the workflow as it is and add the bindings to the module ?
// contributed by org.eclipse.xtext.generator.scoping.AbstractScopingFragment
public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider.class);
}
// contributed by org.eclipse.xtext.generator.scoping.AbstractScopingFragment
public Class<? extends org.eclipse.xtext.scoping.IGlobalScopeProvider> bindIGlobalScopeProvider() {
return org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.class;
}
// contributed by org.eclipse.xtext.generator.exporting.SimpleNamesFragment
public Class<? extends org.eclipse.xtext.naming.IQualifiedNameProvider> bindIQualifiedNameProvider() {
return org.eclipse.xtext.naming.SimpleNameProvider.class;
}
what you do else depends on your rules and how the imports look like.
in a simple case you could adapt iQualifiedNAmeProvider to
give your elements the name
filename.extension.simplename (by looking at the eObjects eResources URI)
and for a import
import "filename.extension"
you create a actual name import filename.extension.*
e.g.
inside org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getImportedNamespace(EObject)
|
|
|
Re: Using ImportURIScopingFragment instead of ImportNamespacesScopingFragment with the new MWE2 [message #1736352 is a reply to message #1736351] |
Tue, 28 June 2016 18:13   |
Eclipse User |
|
|
|
Hello Christian,
thanks a lot for your help.
I made the proposed changes and it works ... almost.
The restriction to the imported files works but now the local name resolution does not work anymore.
Using
override bindIGlobalScopeProvider() {
ImportUriGlobalScopeProvider
}
override configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(
SimpleLocalScopeProvider);
}
override bindIQualifiedNameProvider() {
SimpleNameProvider
}
I cannot use FQN "DSL.Position100.currency" in the model and I must use currency instead
import "DSL-1.0.0.dsl"
variables {
DSL.Position100.currency as fact
}
rule RULE_ID {
fact + fact
}
but using
override bindIGlobalScopeProvider() {
ImportUriGlobalScopeProvider
}
override configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(
SimpleLocalScopeProvider);
}
override bindIQualifiedNameProvider() {
DefaultDeclarativeQualifiedNameProvider
}
The local resolution does not work anymore: "fact" is not recognize while "DSL.Position100.currency as fact" is ok.
import "DSL-1.0.0.dsl"
variables {
DSL.Position100.currency as fact
}
rule RULE_ID {
fact + fact
}
Any clue on the subject
Thanks in advance for your help
|
|
|
|
|
Re: Using ImportURIScopingFragment instead of ImportNamespacesScopingFragment with the new MWE2 [message #1736385 is a reply to message #1736384] |
Wed, 29 June 2016 05:55   |
Eclipse User |
|
|
|
override configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(
SimpleLocalScopeProvider);
}
overrides
public void configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
ImportedNamespaceAwareLocalScopeProvider can do the local relative name import magic.
SimpleLocalScopeProvider cant.
for 2 i cannot follow you. the old fragments are inside org.eclipse.xtext.generator plugin. (the old generator)
maybe your manifest contains org.eclipse.xtext.xtext.generator only (the new generator)
=> add the old one as well
|
|
|
Re: Using ImportURIScopingFragment instead of ImportNamespacesScopingFragment with the new MWE2 [message #1736388 is a reply to message #1736385] |
Wed, 29 June 2016 06:18   |
Eclipse User |
|
|
|
Thanks for the explanation about the configureIScopeProviderDelegate.
Concerning the second point, my question was not about MWE but about the new strategy. In the referenced bug ticket, Sven mentioned that
Quote:
We changed the API of the generator. ImportURI mechanism is discouraged (name based scoping being the better alternative) so we haven't reimplemented it for the new generator infrastructure.
However for backward compatibility we have the FragmentAdapter, so you can write
fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
fragment = org.eclipse.xtext.generator.scoping.ImportURIScopingFragment {}
}
So if the "ImportURI mechanism" is discouraged what should we use instead to limit the visibility to a subset of the files in the workspace.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04353 seconds